文字按钮
iOS倒计时按钮Button标题闪烁处理
https://blog.csdn.net/u011363981/article/details/76687561
Xcode 13/iOS 15 xib使用UIbutton的问题
https://www.jianshu.com/p/393e60667596
https://blog.csdn.net/same_life/article/details/126787878
@property (nonatomic, strong) UIButton *Btn;
- (UIButton *)Btn {
if (!_Btn) {
UIButton *button=[[UIButton alloc]init];
[button setTitle:@"删除" forState:UIControlStateNormal];
[button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
button.titleLabel.font = systemFont(14);
button.layer.borderWidth = 0.5;
button.layer.borderColor = RGB(227, 229, 230).CGColor;
button.layer.cornerRadius = 3;
button.layer.masksToBounds = YES;
[button addTarget:self action:@selector(BtnClick:) forControlEvents:UIControlEventTouchDown];
_Btn = button;
}
return _Btn;
}
#pragma mark ************** 按钮被点击
- (void)BtnClick:(UIButton *)sender{
}
[self.Btn makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self.view);
make.height.equalTo(@30);
make.width.equalTo(@30);
}];
拓展
#pragma 图片上下左右
[_btnLeft layoutButtonWithEdgeInsetsStyle:ButtonEdgeInsetsStyleImageLeft imageTitlespace:5];
#pragma 按钮验证码计时器
JKCountDownButton
图片按钮
- (UIButton *)Btn {
if (!_Btn) {
UIButton *button = [[UIButton alloc]init];
[button setImage:[UIImage imageNamed:@"tab_service"] forState:UIControlStateNormal];
[button.imageView setContentMode:UIViewContentModeScaleAspectFit];
[button addTarget:self action:@selector(BtnClick:) forControlEvents:UIControlEventTouchDown];
_Btn = button;
}
return _Btn;
}
//按钮按下后的模糊状态
[button setAdjustsImageWhenHighlighted:NO];
问题,IB 中的按钮,在代码中设置上面属性是无效的,得继承(MJHighlightedButton)
按钮设置adjustsImageWhenHighlighted无效
https://www.jianshu.com/p/da57449ad89d
UIButton *button=[[UIButton alloc]init];
button.frame = CGRectMake(40, 40, 100, 40);
[button setTitle:@"childVC" forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:0];
[button addTarget:self action:@selector(BtnClick:) forControlEvents:UIControlEventTouchDown];
[self.view addSubview:button];
UIEdgeInsetsMake的使用 网址
http://blog.csdn.net/nlforever/article/details/12967371
http://www.jianshu.com/p/be4543ad4960
https://www.jianshu.com/p/64ab3cdafe89
iOS-UIButton 统计整个App 每个按钮的点击次数
https://www.jianshu.com/p/5e3b4d66ef29