uibutton怎么修改内部image与title的位置
1个回答
展开全部
/**
* 重新布局UIbutton
*
* @param button 所布局的UIbutton
*/
-(void)layoutBtnWithBtn:(UIButton *)button{
button.titleLabel.backgroundColor = button.backgroundColor;
button.imageView.backgroundColor = button.backgroundColor;
CGSize titleSize = button.titleLabel.bounds.size;
CGSize imageSize = button.imageView.bounds.size;
NSLog(@"titleSize :%@ \n imageSize:%@",NSStringFromCGSize(titleSize),NSStringFromCGSize(imageSize));
//文字左移
button.titleEdgeInsets = UIEdgeInsetsMake(0.0, -imageSize.width, 0.0, imageSize.width);
//图片右移
button.imageEdgeInsets = UIEdgeInsetsMake(0.0, titleSize.width, 0.0, -titleSize.width);
}
* 重新布局UIbutton
*
* @param button 所布局的UIbutton
*/
-(void)layoutBtnWithBtn:(UIButton *)button{
button.titleLabel.backgroundColor = button.backgroundColor;
button.imageView.backgroundColor = button.backgroundColor;
CGSize titleSize = button.titleLabel.bounds.size;
CGSize imageSize = button.imageView.bounds.size;
NSLog(@"titleSize :%@ \n imageSize:%@",NSStringFromCGSize(titleSize),NSStringFromCGSize(imageSize));
//文字左移
button.titleEdgeInsets = UIEdgeInsetsMake(0.0, -imageSize.width, 0.0, imageSize.width);
//图片右移
button.imageEdgeInsets = UIEdgeInsetsMake(0.0, titleSize.width, 0.0, -titleSize.width);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询