zoukankan      html  css  js  c++  java
  • UIButton详解

    // ----------------------------------UIButton------------------------------

        // UIButtonTypeSystem 点击文字会有效果,变色  UIButtonTypeCustom 无点击效果

        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

        button.frame = CGRectMake(200, 100, 200, 80);

        [button setTitle:@"click me" forState:UIControlStateNormal];

        button.backgroundColor = [UIColor blueColor];

        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];

        // 字体大小

        button.titleLabel.font = [UIFont systemFontOfSize: 20.0];

    //    button.font = [UIFont systemFontOfSize:20];  废弃

        //边框

        button.layer.borderWidth = 3;

        button.layer.borderColor = [UIColor grayColor].CGColor;

        // 设置圆角

        [button.layer setMasksToBounds:YES];

        [button.layer setCornerRadius:20.0];

        // 按下会有发光的效果

        button.showsTouchWhenHighlighted = YES;

        

        // 文字居左

        button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;

        // 文字居顶

        button.contentVerticalAlignment = UIControlContentVerticalAlignmentTop;

        

        // 文字内边距

        button.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 0, 0);

        

        [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];

  • 相关阅读:
    回溯算法
    回溯算法
    回溯算法
    回溯算法思想
    贪心算法
    C#多线程操作界面控件的解决方案
    jQuery教程
    html css JavaScript网页渲染
    jQuery与JavaScript与ajax三者的区别与联系
    asp.net MVC中form提交和控制器接受form提交过来的数据
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4896078.html
Copyright © 2011-2022 走看看