let label = UILabel()
UILabel *label = [[UILabel alloc] init];
or
UILabel *label = [UILabel new]; // convenience method for calling 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];
The font and point size will be based on the user's preferred reading size.
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];
A way to set the font size without knowing the font family is to use the font property of the UILabel
.
label.font = label.font.fontWithSize(15)
label.font = label.font.withSize(15)
label.font = [label.font fontWithSize:15];