按钮常见的访问方法
当前图片:
[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
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。