嘿家伙, 有谁知道如何让文本视图透明并在文本视图后添加背景图片?谢谢在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. 在vim中添加背景图片
- 3. 在css中添加背景图片
- 4. 在安卓graphview添加背景图片
- 5. 在pygames中添加背景图片?
- 6. Cocos2d为图层添加背景图片?
- 7. 将UIImageView添加到NavigationBar的背面(不是背景图片)
- 8. 叠加在背景图片
- 9. 添加背景图片直销收藏
- 10. 添加背景图片Bootstrap Jumbotron
- 11. 添加ID号到背景图片
- 12. 添加背景图片到nnavigation rootview
- 13. 添加背景图片使用PhotoChooserTask
- 14. 添加背景图片的UITabBarController
- 15. 如何为UIWebView添加背景图片?
- 16. 向TTWebController的UIToolbar添加背景图片
- 17. 不能添加背景图片的CSS
- 18. 创建div并添加背景图片
- 19. 尝试添加背景图片?
- 20. CSS:添加填充到背景图片
- 21. 添加背景图片阵营JS
- 22. iPhone OpenGL:添加背景图片
- 23. 通过css添加背景图片
- 24. 如何添加内联背景图片?
- 25. 如何动态添加背景图片?
- 26. gif加载后更改背景图片?
- 27. 在背景图片上添加JPanel /容器/图片/ JButtons /等等?
- 28. Bootstrap。页面背景图片
- 29. Bootstrap - 全屏幕标题图片,后面是背景图片
- 30. Xamarin Forms - 如何将背景图片添加到内容页面