Ios-ui-elements-labels
提供:Dev Guides
iOS-ラベル
ラベルの使用
ラベルは、単一行または複数行で構成される静的コンテンツを表示するために使用されます。
重要なプロパティ
- textAlignment
- テキストの色
- text
- numberOflines *lineBreakMode
カスタムメソッドaddLabelを追加する
-(void)addLabel {
UILabel* aLabel = [[UILabel alloc]initWithFrame:
CGRectMake(20, 200, 280, 80)];
aLabel.numberOfLines = 0;
aLabel.textColor = [UIColor blueColor];
aLabel.backgroundColor = [UIColor clearColor];
aLabel.textAlignment = UITextAlignmentCenter;
aLabel.text = @"This is a sample text\n of multiple lines.
here number of lines is not limited.";
[self.view addSubview:aLabel];
}
次のようにViewController.mのviewDidLoadを更新します-
- (void)viewDidLoad {
[super viewDidLoad];
//The custom method to create our label is called
[self addLabel];
//Do any additional setup after loading the view, typically from a nib.
}
出力
アプリケーションを実行すると、次の出力が得られます-