0

UILabeliOSアプリケーションを開発していますが、このような画像のスタイルを設定したいと思います。画像http://img4.hostingpics.net/thumbs/mini_388558Capturedcran20120629142330.png

これを行うことは可能ですか?

4

2 に答える 2

1

解決策は、通常どおりにを作成してから、の空の部分の上にUILabel黒を配置することです。テキストのフォントのサイズに基づいて、実際に配置する場所を計算できます。UIViewUILabel

于 2012-06-29T12:36:05.477 に答える
1

解決策は、ラッパー UIView のサブビューとして UILabel を追加することです

// Using ARC

// Set Wrapper
CGRect wrapperFrame = CGRectMake(0, 0, 320, 80);
UIView *specialLabel = [[UIView alloc] initWithFrame:wrapperFrame];
[specialLabel setBackgroundColor:[UIColor blackColor]];

// Set Content
CGFloat padding = 10;
CGRect contentFrame = CGRectInset(wrapperFrame, padding, padding);
UILabel *contentLabel = [[UILabel alloc] initWithFrame:contentFrame];
[contentLabel setBackgroundColor:[UIColor greenColor]];

// Append content to wrapper
[specialLabel addSubview:contentLabel];
于 2012-06-29T14:28:21.433 に答える