2012-03-01 50 views
1

目前,我這樣做是爲了對我的UITextView背景圖片:重複UITextView的背景圖像?

UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, textView.frame.size.width, textView.frame.size.height)]; 
imgView.image = [UIImage imageNamed:@"background.png"]; 
[textView addSubview: imgView]; 
[textView sendSubviewToBack: imgView]; 
[imgView release]; 

但問題是,它不會重複。我想要的是在每個UIImage之後重複的圖像。

這可能嗎?

謝謝!

+0

你的意思是平鋪效果? – Snips 2012-03-01 20:51:49

+0

沒有一個圖像在另一個圖像上 – 2012-03-01 21:04:44

+0

一個圖像分層疊加在另一個(分層)上,或者一個在另一個上面(不重疊)? – Snips 2012-03-01 23:23:43

回答

11
textView.backgroundColor = [UIColor colorWithPatternImage:[UIImage [email protected]"background"]]; 

是,忽略從圖像名稱巴紐,它可以讓你提供的Retina版本[email protected]

+0

不,我只是試過了,這不是我想要的,我只是想要一個接一個的垂直圖像。沒有圖案。 – 2012-03-01 21:35:10

+1

事實證明,我的形象是明智的命名混亂,它現在使用你的方式。再次感謝! – 2012-03-04 07:06:51