button上图片在上,文字在下并且居中显示:
-(void)setButtonContentCenter:(UIButton *) btn{
CGSizeimgViewSize,titleSize,btnSize;
UIEdgeInsetsimageViewEdge,titleEdge;
CGFloatheightSpace =5.0f;
//设置按钮内边距
imgViewSize = btn.imageView.bounds.size;
titleSize = btn.titleLabel.bounds.size;
btnSize = btn.bounds.size;
imageViewEdge =UIEdgeInsetsMake(heightSpace,0.0, btnSize.height-imgViewSize.height- heightSpace, - titleSize.width);
[btnsetImageEdgeInsets:imageViewEdge];
titleEdge =UIEdgeInsetsMake(imgViewSize.height+heightSpace+3, - imgViewSize.width,0.0,0.0);
[btnsetTitleEdgeInsets:titleEdge];
}