• UIButton的圆角


    _interestedBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _interestedBtn.layer.cornerRadius = 8;

        _interestedBtn.layer.borderColor = [UIColor orangeColor].CGColor;

        _interestedBtn.layer.borderWidth = 1;

        _interestedBtn.layer.masksToBounds = YES;

        [_interestedBtn setTitle:@"感兴趣" forState:UIControlStateNormal];

        [_interestedBtn setTitle:@"已感兴趣" forState:UIControlStateSelected];

        [_interestedBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];

        [_interestedBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateSelected];

        [_interestedBtn addTarget:self action:@selector(interestedBtnAction:) forControlEvents:UIControlEventTouchUpInside];

        [self.contentView addSubview:_interestedBtn];

    -(void)interestedBtnAction:(UIButton *)sender{

        sender.selected = !sender.selected;

        

        if (sender.selected) {

            _interestedBtn.layer.cornerRadius = 8;

            _interestedBtn.layer.borderColor = [UIColor lightGrayColor].CGColor;

            _interestedBtn.layer.borderWidth = 1;

            _interestedBtn.layer.masksToBounds = YES;

        }else{

            _interestedBtn.layer.cornerRadius = 8;

            _interestedBtn.layer.borderColor = [UIColor orangeColor].CGColor;

            _interestedBtn.layer.borderWidth = 1;

            _interestedBtn.layer.masksToBounds = YES;

        }

    }

    1
  • 相关阅读:
    C#高级特性_Attribute
    C#高级特性_Lambda
    委托(delegate)
    C# 属性、索引
    C#中的interface
    枚举型Enum和结构型Stuct
    javascript学习笔记
    github page 和 hexo 搭建在线博客
    2015/9/22 开通博客园
    phoenix 入门
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5539166.html
Copyright © 2020-2023  润新知