按钮常见的访问方法
当前图片:
[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
网友评论