ios – 自定义UIButton触摸时不突出显示

ios – 自定义UIButton触摸时不突出显示,第1张

概述我有一个方法创建一个自定义UIButton,允许我使用QuartzCore更改按钮的颜色.但触摸时按钮不会突出显示. - (UIButton *)makeHeaderButton { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; UIFont *textFont = [UIFont boldSyst 我有一个方法创建一个自定义UIbutton,允许我使用QuartzCore更改按钮的颜色.但触摸时按钮不会突出显示.
- (UIbutton *)makeheaderbutton {    UIbutton *button = [UIbutton buttonWithType:UIbuttonTypeCustom];    UIFont *textFont = [UIFont boldSystemFontOfSize:12];    UIcolor *textcolor = [UIcolor colorWithRed:80/255.0 green:109/255.0 blue:145/255.0 Alpha:1.0];    UIcolor *backgroundcolor = [UIcolor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 Alpha:1.0];    [button setTitlecolor:textcolor forState:UIControlStatenormal];    button.TitleLabel.Font = textFont;    button.autoresizesSubvIEws = YES;    button.layer.cornerRadius = 8;    button.layer.borderWIDth = 1;    // next 2 propertIEs set using QuartzCore class,no other way to set button colors    button.layer.bordercolor = [UIcolor graycolor].CGcolor;    button.layer.backgroundcolor = backgroundcolor.CGcolor;    button.clipsToBounds = YES;    return button;}

如何使这些按钮像常规的圆形按钮一样突出显示?

解决方法 在你的代码中,添加一行button.showstouchWhenHighlighted = TRUE; 总结

以上是内存溢出为你收集整理的ios – 自定义UIButton触摸时不突出显示全部内容,希望文章能够帮你解决ios – 自定义UIButton触摸时不突出显示所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1112921.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存