広告
UILabel を使って文字列を表示する際の文字の大きさは setFont で文字サイズの値を持つ UIFont のインスタンスを指定して行います。
フォントの種類はそのままで文字サイズだけ変更したい場合は UIFont の fontWithSize を使って種類はそのままでサイズだけ変更した UIFont のインスタンスを生成して使います。
広告
フォントサイズ16 サンプル
- (void)sampleUILabelSetFontSystemFont16 { UILabel *label = [[UILabel alloc] initWithFrame:viewFrame] ; [label setText:@"Sample Font Size Text 16.0"] ; [label setFont:[UIFont systemFontOfSize:16.0]] ; [self.view addSubview:label] ; }
フォントサイズ16 表示結果

フォントサイズ24 サンプル
- (void)sampleUILabelSetFontSystemFont24 { UILabel *label = [[UILabel alloc] initWithFrame:viewFrame] ; [label setText:@"Sample Font Size Text 24.0"] ; [label setFont:[UIFont systemFontOfSize:24.0]] ; [self.view addSubview:label] ; }
フォントサイズ24 表示結果

サイズのみ変更 サンプル
- (void)sampleUILabelSetFontSize12 { UILabel *label = [[UILabel alloc] initWithFrame:viewFrame] ; [label setText:@"Sample Font Size Text 12.0"] ; [label setFont:[label.font fontWithSize:12.0]] ; [self.view addSubview:label] ; }
サイズのみ変更 表示結果

広告
広告