假设有按钮rButton的 imageEdgeInsets和contentEdgeInsets可以设置按钮的标题和图片的位置,如下代码,设置标题居右

    NSString * rBtnTitle = @"删除";
    CGSize size = [rBtnTitle sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11]}];
    NSLog(@"size = %@",NSStringFromCGSize(size));
    
    CGFloat leftPadding = CGRectGetWidth(rBtn.frame) - size.width;
    rBtn.contentEdgeInsets = UIEdgeInsetsMake(0, leftPadding, 0, 0);

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2022-12-23
  • 2022-01-18
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案