嘿家伙, 有谁知道如何让文本视图透明并在文本视图后添加背景图片?谢谢在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. 如何动态添加背景图片?