tips

UIbutton 上下图片文字布局

2018-07-05  本文已影响25人  crazyfox
//设置文字偏移:向下偏移图片高度+向左偏移图片宽度 (偏移量是根据[图片]大小来的,这点是关键)
_baseInfoButton.titleEdgeInsets = UIEdgeInsetsMake(_baseInfoButton.imageView.frame.size.height, -_baseInfoButton.imageView.frame.size.width, 0, 0);

//设置图片偏移:向上偏移文字高度+向右偏移文字宽度 (偏移量是根据[文字]大小来的,这点是关键)
_baseInfoButton.imageEdgeInsets = UIEdgeInsetsMake(-_baseInfoButton.titleLabel.frame.size.height,0,0,-_baseInfoButton.titleLabel.bounds.size.width);
上一篇 下一篇

猜你喜欢

热点阅读