UIButton *EndBut = [UIButton buttonWithType:UIButtonTypeCustom];
EndBut.frame = CGRectMake(Screen_W-47*YZAdapter, 0, 35*YZAdapter, 43);
[EndBut setImage:[UIImage imageNamed:@"已完成订单"] forState:UIControlStateNormal];
[EndBut setTitle:@"已完成" forState:UIControlStateNormal];
EndBut.titleLabel.font = FONT(10);
[EndBut setTitleColor:MainFont_Color forState:UIControlStateNormal];
EndBut.backgroundColor = YZBackNavColor;
EndBut.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;//使图片和文字水平居中显示
[EndBut setTitleEdgeInsets:UIEdgeInsetsMake(EndBut.imageView.frame.size.height+2*YZAdapter ,-EndBut.imageView.frame.size.width, 0.0,0.0)];//文字距离上边框的距离增加imageView的高度,距离左边框减少imageView的宽度,距离下边框和右边框距离不变
[EndBut setImageEdgeInsets:UIEdgeInsetsMake(-EndBut.titleLabel.bounds.size.height, 0.0,0.0, -EndBut.titleLabel.bounds.size.width)];//图片距离右边框距离减少图片的宽度,其它不边 [self.view addSubview:EndBut];
网友评论