zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Python面向对象-类成员
    python面向对象-继承
    Linux 静态和动态添加路由
    Linux 添加虚拟网卡
    centos7源码包安装Mongodb,并设置开机自启动
    centos7配置静态ip地址
    Python开发【前端篇】JavaScript和Jquery
    Python爬虫【解析库之pyquery】
    Python爬虫 selenium
    Python爬虫【解析库之beautifulsoup】
  • 原文地址:https://www.cnblogs.com/fantasy3588/p/5539166.html
Copyright © 2011-2022 走看看