项目"/>
[iOS微博项目
github:A.转发微博部分的淡灰色背景 1.需求
- 转发微博部分需要设置背景色
- 使用图片作为背景
- 直接设置view的背景图片,使用UIColor的平铺图片
- 实现view的drawRect方法,拉伸背景图片(把背景图片画到整个view上)
- 令转发微博view继承ImageView,直接设置图片,这样还可以设置高亮图片
1 // 设置背景 2 // 使用平铺方式设置背景图片 3 self.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithNamed:@"timeline_retweet_background"]];但是由于是平铺图片,图片的上下边缘部分会形成很多"细线" (2)实现drawRect
1 - (void)drawRect:(CGRect)rect { 2 [[UIImage imageWithNamed:@"timeline_retweet_background"] drawInRect:self.bounds]; 3 }(3)改变view的父类为ImageView,直接设置image属性
1 // 设置背景图片 2 [self setImage:[UIImage imageWithNamed:@"timeline_retweet_background"]]; 3 [self setHighlightedImage:[UIImage imageWithNamed:@"timeline_retweet_background_highlighted"]];
转载于:.html
更多推荐
[iOS微博项目
发布评论