美文网首页
iOS开发常见问题-按钮Button

iOS开发常见问题-按钮Button

作者: 年轻岁月 | 来源:发表于2016-06-25 10:16 被阅读87次

按钮常见的访问方法

当前图片:
[button imageForState:UIControlStateNormal].size;
button.currentImage.size;

背景图片:
[button backgroundImageForState:UIControlStateNormal];
button.currentBackgroundImage;

当前标题:
[button titleForState:UIControlStateNormal];
button.currentTitle;

标题颜色:
[button titleColorForState:UIControlStateNormal];
button.currentTitleColor;

设置按钮的内边距

整个内容的内边距:
@property(nonatomic) UIEdgeInsets contentEdgeInsets UI_APPEARANCE_SELECTOR;
标题的内边距:
@property(nonatomic) UIEdgeInsets titleEdgeInsets;
图片的内边距:
@property(nonatomic) UIEdgeInsets imageEdgeInsets;

viewWithTag:内部的大致实现思路

@implementation UIView
- (UIView *)viewWithTag:(NSInteger)tag
{
    if (self.tag == tag) return self;

    for (UIView *subview in self.subviews) {
        return [subview viewWithTag:tag];
    }
}
@end

相关文章

网友评论

      本文标题:iOS开发常见问题-按钮Button

      本文链接:https://www.haomeiwen.com/subject/zfhadttx.html