How to achieve UIButton / UILabel 'padding' in iPhone app

前端 未结 10 2069
挽巷
挽巷 2021-01-31 13:40

I\'ve got various views in my iPhone application that require padding e.g a custom UIButton with text aligned left, and a UILabel with a background color.

This may be a

10条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 13:54

    If you're just looking for a horizontal padding on one line, then this may be enough (it was for me):

    NSString* padding = @"  "; // 2 spaces
    myLabel.text = [NSString stringWithFormat:@"%@%@%@", padding, name, padding];
    

提交回复
热议问题