Paquete de uso simple de iOS sobre UILabel

  • archivo .m

#import "BaseLabel.h"

@implementation BaseLabel

+(instancetype)labelWithFrame:(CGRect)frame
                         text:(NSString *)text
                    textColor:(UIColor *)textColor
                         font:(UIFont *)font
                textAlignment:(NSTextAlignment)textAlignment
              backgroundColor:(UIColor *)bgColor
{
    BaseLabel *szkLabel=[[BaseLabel alloc]initWithFrame:frame];
    szkLabel.text=text;
    szkLabel.textColor=textColor;
    szkLabel.font=font;
    szkLabel.textAlignment=textAlignment;
    szkLabel.backgroundColor=bgColor;
    return szkLabel;
}
  • .h

    @interface BaseLabel : UILabel
    +(instancetype)labelWithFrame:(CGRect)frame
               text:(NSString *)text
          textColor:(UIColor *)textColor
               font:(UIFont *)font
      textAlignment:(NSTextAlignment)textAlignment
    backgroundColor:(UIColor *)bgColor;
    @end

Supongo que te gusta

Origin blog.csdn.net/hezhi66327/article/details/128827446
Recomendado
Clasificación