2012-01-20 12 views

回答

3

設置圖像作爲背景圖像

theLabel.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blah"]]; 

和寫入文本

thelabel.text = @"abc" 

設置標籤

[thelabel setTextAlignment:UITextAlignmentLeft]; 
+0

這不會重複圖像嗎?這發生在iOS模擬器中。 – newenglander

1

我不確定您實際上可以將圖像放入UILabel中,但如果可以的話,您將使用addSubView:方法。

UILabel *label = .... 
label.text = @"Hi there"; 

UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(x,y,width,height)]; 
[label addSubView:image]; 

試試吧,看看它是否工作,如果沒有,那麼你可能需要圖像的幀設置爲與標籤的彩車沿着框架。

+0

的對齊我想你「爲無可見@interface 'UILabel'聲明選擇器'addSubView:'「 –