如何编写一种方法来控制所有标签或 textView?

How can I write one method to control all of the labels or textView?

我在不同的页面上有很多 LabelsTextViewTextField。我如何编写一个方法来控制所有标签或 textView 的字体类型、字体大小,或检查 6 个文本字段是否为空?有办法吗?而不是像这样写长代码

 if ((txtfldFirst.text && txtfldFirst.text.length && txtfldLast.text && txtfldLast.text.length && txtfldPhone.text && txtfldPhone.text.length && txtfldEmail.text && txtfldEmail.text.length && txtViewComment.text && txtViewComment.text.length) )


[txt1 setFont:[UIFont fontWithName:@"GalaxiePolaris-Book" size:16.0]];
[txt2 setFont:[UIFont fontWithName:@"GalaxiePolaris-Book" size:16.0]];
[txt3 setFont:[UIFont fontWithName:@"GalaxiePolaris-Book" size:16.0]];
[txt4 setFont:[UIFont fontWithName:@"GalaxiePolaris-Book" size:16.0]];
...
.....

创建子类。

New file -> iOS -> Source -> Cocoa Touch Class -> 
-> MyLabel; subclass of UILabel

在.m文件中写入:

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = super initWithFrame:frame]) {
        self.font = [UIFont fontWithName:@"GalaxiePolaris-Book" size:16.0];
    }

    return self;
}

然后在您的控制器或视图中而不是

UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];

写:

MyLabel *label = [[MyLabel alloc] initWithFrame:CGRectZero];