-(void)initButton:(UIButton*)btn{
? ? float? spacing =3;//圖片和文字的上下間距
? ? CGSize imageSize = btn.imageView.frame.size;
? ? CGSize titleSize = btn.titleLabel.frame.size;
? ? CGSize textSize = [btn.titleLabel.text sizeWithAttributes:@{NSFontAttributeName : btn.titleLabel.font}];
? ? CGSizeframeSize =CGSizeMake(ceilf(textSize.width),ceilf(textSize.height));
? ? if(titleSize.width+0.5< frameSize.width) {
? ? ? ? titleSize.width= frameSize.width;
? ? }
? ? CGFloattotalHeight = (imageSize.height+ titleSize.height+ spacing);
? ? btn.imageEdgeInsets=UIEdgeInsetsMake(- (totalHeight - imageSize.height),0.0,0.0, - titleSize.width);
? ? btn.titleEdgeInsets=UIEdgeInsetsMake(0, - imageSize.width, - (totalHeight - titleSize.height),0);
}