swift 自定义UIButton 图片在上 文字在下
1 首先继承UIButton
2 实现imageRectForContentRect titleRectForContentRect
// 内部图片的frame
- (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // 图标居中 self.imageView.contentMode = UIViewContentModeCenter; // 文字居中 self.titleLabel.textAlignment = NSTextAlignmentCenter; } return self; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |