http://www.2cto.com/kf/201311/259154.html
一行代码移除所有子视图
//要删除当前View的所有子View下面一行代码即可搞定
[self.view.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
在UIButton上添加UIActivityIndicator及设置大小
- (IBAction)didClickAddFriend:(id)sender
{
//将文字置空
[self.addFriendButton setTitle:nil forState:UIControlStateNormal];
//初始化系统小菊花
UIActivityIndicatorView *addFriendActivityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:self.addFriendButton.bounds];
[addFriendActivityIndicator setUserInteractionEnabled:YES];
[addFriendActivityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
//改变小菊花颜色
[addFriendActivityIndicator setColor:[UIColor green1Color]];
//下文去解释下面这两行行代码的作用
//CGAffineTransform transform = CGAffineTransformMakeScale(.7f, .7f);
//addFriendActivityIndicator.transform = transform;
[self.addFriendButton addSubview:addFriendActivityIndicator];
//小菊花开始转圈圈
[addFriendActivityIndicator startAnimating];
//用block实现加好友操作
if ([self addFriendHandler]) {
self.addFriendHandler();
}
}
UIButton中设置图片与标题位置的解决方案 good
UIButton实现各种图文结合的效果以及原理 good
iOS经典讲解之UIButton改变图片和文字的位置
按钮UIButton内图片和文字位置的设置(两种方式)
layoutSubviews