嘿傢伙, 有誰知道如何讓文本視圖透明並在文本視圖後添加背景圖片?謝謝在TextView後面添加背景圖片
2
A
回答
5
在viewDidLoad中
textView.backgroundColor = [UIColor clearColor];
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:textView.frame] autorelease];
imageView.image = [UIImage imageNamed:@"myBackgroundImage.png"];
[self.view addSubview:imageView];
[self.view bringSubviewToFront:textView];
2
試着做一個新班。 (沒有測試代碼,只需鍵入它在論壇上,嘗試以其他方式使用代碼:使用的概念)
@interface TextViewWithImage : UIView {
UITextView *textView;
UIImageView *imageView;
}
@property (retain, readonly) UITextView *textView;
@property (retain, readonly) UIImageView *imageView;
@implementation TextViewWithImage
- (id) init {
if (self = [super init]) {
[self setupContentViews];
}
return self;
}
- (id) initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self setupContentViews];
}
return self;
}
- (void) setupContentViews {
textView = [[UITextView alloc] init];
imageView = [[UIImageView alloc] init];
textView.frame = self.frame;
imageView.frame = self.frame;
textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (void) dealloc {
[textView release];
[imageView release];
[super dealloc];
}
@end
0
UIViews(其中的UITextView是一個子類)有一個名爲backgroundColor的屬性。
@property(nonatomic, copy) UIColor *backgroundColor
嘗試調用[TextView的setBackgroundColor:的UIColor clearColor]]關於TextView的,並把它後面的圖像視圖。
相關問題
- 1. 如何在容器後面添加背景圖片
- 2. 添加背景圖片並在圖片上添加文字
- 3. 在邊緣內添加背景圖片
- 4. 添加背景圖片在PDF(ABCpdf)
- 5. 添加多背景圖片在CSS
- 6. 在vim中添加背景圖片
- 7. 在css中添加背景圖片
- 8. 在背景圖片上添加填充
- 9. 在安卓graphview添加背景圖片
- 10. 在pygames中添加背景圖片?
- 11. Cocos2d爲圖層添加背景圖片?
- 12. 將UIImageView添加到NavigationBar的背面(不是背景圖片)
- 13. 疊加在背景圖片
- 14. 更改背景圖片textView按下時
- 15. 添加背景圖片的UITabBarController
- 16. 添加背景圖片陣營JS
- 17. 創建div並添加背景圖片
- 18. iPhone OpenGL:添加背景圖片
- 19. 如何添加內聯背景圖片?
- 20. jquery沒有添加背景圖片div
- 21. 如何爲ActionBar添加背景圖片?
- 22. CSS:添加填充到背景圖片
- 23. 添加背景圖片到鏈接?
- 24. 如何爲UIWebView添加背景圖片?
- 25. jQuery選擇:添加背景圖片?
- 26. 添加背景圖片Bootstrap Jumbotron
- 27. 添加背景圖片使用PhotoChooserTask
- 28. 添加背景圖片到nnavigation rootview
- 29. 嘗試添加背景圖片?
- 30. 如何動態添加背景圖片?