iOS 快速UIButton 左边文字、右边按钮

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"image"] forState:UIControlStateNormal];
    [button setTitle:@"左边文字,右边图片" forState:UIControlStateNormal];
    [button setTitleEdgeInsets:UIEdgeInsetsMake(0, - button.imageView.image.size.width, 0, button.imageView.image.size.width)];
    [button setImageEdgeInsets:UIEdgeInsetsMake(0, button.titleLabel.bounds.size.width, 0, -button.titleLabel.bounds.size.width)];

你可能感兴趣的:(iOS 快速UIButton 左边文字、右边按钮)