UIButton 使用注意事项

来源:互联网 发布:新唐单片机官网 编辑:程序博客网 时间:2024/05/29 15:35

UIButton 使用注意事项:
1 当UIButton结合Mansory使用时,注意使用

- (void)setBackgroundImage:(nullable UIImage *)image forState:(UIControlState)state  

方法,
因为经由这个方法设置的图片会紧粘着UIButton的边界,也就是
@property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR; // default is
的属性将不能生效,且后期使用很麻烦;
所以,改用

- (void)setImage:(nullable UIImage *)image forState:(UIControlState)state;  

则无此问题,这样就可以达到UIButton点击区域比image要大的效果。

0 0
原创粉丝点击