let label = UILabel()
UILabel *label = [[UILabel alloc] init]; or UILabel *label = [UILabel new]; // 调用alloc-init的便捷方法
label.font = UIFont.systemFontOfSize(17)
label.font = UIFont.systemFont(ofSize: 17)
label.font = [UIFont systemFontOfSize:17];
label.font = UIFont.systemFontOfSize(17, weight: UIFontWeightBold)
label.font = UIFont.systemFont(ofSize: 17, weight: UIFontWeightBold)
label.font = [UIFont systemFontOfSize:17 weight:UIFontWeightBold];
label.font = UIFont.boldSystemFontOfSize(17)
label.font = UIFont.boldSystemFont(ofSize: 17)
label.font = [UIFont boldSystemFontOfSize:17];
字体和磅值将基于用户的首选阅读大小。
label.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
label.font = UIFont.preferredFont(forTextStyle: .body)
label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
label.font = UIFont(name: "Avenir", size: 15)
label.font = [UIFont fontWithName:@"Avenir" size:15];
在不知道字体系列的情况下设置字体大小的一种方法是使用的font属性UILabel。
label.font = label.font.fontWithSize(15)
label.font = label.font.withSize(15)
label.font = [label.font fontWithSize:15];