美文网首页
UIButton的基本使用

UIButton的基本使用

作者: 求长生 | 来源:发表于2020-04-04 11:09 被阅读0次

    常用方法

    self.newBtn =  ({
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.layer.cornerRadius = (48) / 2;
            btn.layer.borderWidth = 1;
            btn.layer.borderColor = [UIColor colorWithHexString:@"#CCCCCC"].CGColor;
            [btn setImage:[UIImage imageNamed:@"nav_wihet"] forState:UIControlStateNormal];
            [btn setImage:[UIImage imageNamed:@"nav_wihet"] 
    forState:UIControlStateSelected];
          [btn setFrame:CGRectMake(0, 0, 48, 44)];
          [btn setImageEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)]; //扩大响应区范围设置图片对应边距
            [btn setTitle:[NSString stringWithFormat:@"  %@",[@"Face Filter" localString]] forState:UIControlStateNormal];
            btn.titleLabel.font = [UIFont systemFontOfSize:15];
            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            [btn addTarget:self action:@selector(fullScreenAction) forControlEvents:UIControlEventTouchUpInside];
    
    btn;
    
    });
    

    相关文章

      网友评论

          本文标题:UIButton的基本使用

          本文链接:https://www.haomeiwen.com/subject/bkbooctx.html