我設置的按鈕標題和圖像都..但我面臨的問題..我的按鈕標題重疊的圖像。按鈕標題隱藏按鈕圖像的iOS
我的代碼是
-(void)addImageonbtn:(UIButton *)Button{
[Button setImage:[UIImage imageNamed:@"drop_bg"] forState:UIControlStateNormal];
Button.imageEdgeInsets = UIEdgeInsetsMake(0, Button.frame.size.width, 0, 24);
Button.titleEdgeInsets = UIEdgeInsetsMake(0, -37, 0, 0);
Button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
Button.layer.borderWidth=1;
Button.layer.borderColor=[UIColor colorWithRed:5/255.0 green:195/255.0 blue:249/255.0 alpha:1.0].CGColor;
Button.clipsToBounds=YES;
}
你應創建一個具有UILabel和UIImageView的組件,將UILabel的寬度限制爲UIImageView的起始X,它不會重疊。 – iphonic