1、应用场景,文字居左,图片居中
//设置图片间距,使其居右对齐 btn.imageEdgeInsets = UIEdgeInsetsMake(0,btn.size.width - 12 - btn.imageView.image.size.width, 0, 0); //文字居左对齐 btn.titleEdgeInsets = UIEdgeInsetsMake(0, -(btn.imageView.image.size.width), 0, 0); //设置文字居左且中心对齐 [btn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; [btn setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
时间: 2024-10-08 06:32:44