[iOS微博项目

编程入门 行业动态 更新时间:2024-10-26 12:23:21

[iOS微博<a href=https://www.elefans.com/category/jswz/34/1771421.html style=项目"/>

[iOS微博项目

github:
A.转发微博部分的淡灰色背景 1.需求
  • 转发微博部分需要设置背景色
  • 使用图片作为背景
2.思路 方法有:
  • 直接设置view的背景图片,使用UIColor的平铺图片
  • 实现view的drawRect方法,拉伸背景图片(把背景图片画到整个view上)
  • 令转发微博view继承ImageView,直接设置图片,这样还可以设置高亮图片
3.实现 (1)直接设置backgroundColor,平铺图片
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微博项目

本文发布于:2024-02-04 14:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1673207.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!