- (void)layoutButton:(UIButton*)btn AndBtnImage:(NSString*)img AndBtnTitle:(NSString*)title AndTitleColor:(UIColor*)titleColor AndBackgroundColor:(UIColor*)bgColor{
? ? [btnsetImage:[UIImage imageNamed:img] forState:UIControlStateNormal];
? ? [btnsetTitle:title forState:UIControlStateNormal];
? ? [btnsetTitleColor:titleColor forState:UIControlStateNormal];
? ? btn.backgroundColor= bgColor;
? ? //設(shè)置文字偏移:向下偏移圖片高度+向左偏移圖片寬度 (偏移量是根據(jù)[圖片]大小來的,這點是關(guān)鍵)
? ? btn.titleEdgeInsets = UIEdgeInsetsMake(btn.imageView.frame.size.height+10, -btn.imageView.frame.size.width, 0, 0);
? ? //設(shè)置圖片偏移:向上偏移文字高度+向右偏移文字寬度 (偏移量是根據(jù)[文字]大小來的,這點是關(guān)鍵)
? ? btn.imageEdgeInsets = UIEdgeInsetsMake(-btn.titleLabel.bounds.size.height-5, 0, 0, -btn.titleLabel.bounds.size.width);
}