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];

  • 相关阅读:
    类与继承
    闭包、原型链和继承
    ajax(下)和“承诺”
    ajax(上)
    Ubuntu电源键软关机设置
    金老师语录摘要(七)
    金老师语录摘要(六)
    金老师语录摘要(四)
    金老师语录摘要(三)
    金老师语录摘要(二)
  • 原文地址:https://www.cnblogs.com/xiangjune/p/4896078.html
Copyright © 2011-2022 走看看