私はUILabel
習慣を入れてUIImageView
います、そして、テキストは切り取られています:
コード:
//self.frame.size.width and height are the same value, self is a square
self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (self.frame.size.width - 12), (self.frame.size.height - 12))];
self.displayNameLabel.center = CGPointMake((self.frame.size.width / 2), (self.frame.size.height / 2));
self.displayNameLabel.backgroundColor = [UIColor whiteColor];
self.displayNameLabel.textAlignment = UITextAlignmentCenter;
self.displayNameLabel.font = [UIFont fontWithName:labelFont size:40];
self.displayNameLabel.adjustsFontSizeToFitWidth = YES;
フォントサイズを大きく設定してから、できるだけ大きくするために使用adjustsFontSizeToFitWidth
します。それは述べています:
ただし、このプロパティがYESに設定されていて、textプロパティのテキストがラベルの境界矩形を超えている場合、レシーバーは文字列が収まるまでフォントサイズを縮小し始めます。
label.frameを次のように設定した場合:
self.displayNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, (self.frame.size.width - 0), (self.frame.size.height - 0))];
その後、意図したとおりに機能します。
フレームを次のように設定するにはどうすればよいですか。
self.frame.size.width
self.frame.size.height
それ以外の:
self.frame.size.width - 14
self.frame.size.height - 14
仕事?
なぜ上部がクリップされるのですか?