• [iOS微博项目


    A.设置每条微博边框样式
    1.需求
    不需要分割线
    每个微博之间留有一定的间隙
     
    2.思路
    • 直接设置分割线样式为none就可以去除分割线
    • 设置tableView的背景色
    • 让每个cell的y值下移10个单位,做出间隙效果
    • 使用资源包内的背景图片类填充cell背景
     
    3.实现
    (1)去除默认分割线
     1 //  HVWHomeViewController.m
     2 - (void)viewDidLoad {
     3     [super viewDidLoad];
     4    
     5     self.tableView.delegate = self;
     6    
     7     // 设置导航栏
     8     [self setupNavigationBar];
     9    
    10     // 获取用户信息
    11     [self setupUserInfo];
    12    
    13     // 添加刷新器
    14     [self addRefresh];
    15    
    16     // 设置tableView背景颜色
    17     self.tableView.backgroundColor = HVWColor(211, 211, 211);
    18     // 设置"不需要分割线"
    19     self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    20 }
     
    Image(155)
     
    (2)设置每个cell之间的间隙
    a.每个微博内容frame下移10个单位
    1 //  HVWStatusContentFrame.m
    2     // 自己的frame
    3     CGFloat contentX = 0;
    4     CGFloat contentY = 10; // 下移10个单位
    5     CGFloat contentWidth = HVWScreenWidth;
    6     self.frame = CGRectMake(contentX, contentY, contentWidth, contentHeight);
     
    b.清除cell背景色
     1 //  HVWStatusCell.m
     2 /** 创建 */
     3 + (instancetype) cellWithTableView:(UITableView *)tableView {
     4     static NSString *ID = @"HVWStatusCell";
     5     HVWStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
     6    
     7     if (nil == cell) {
     8         cell = [[self alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
     9     }
    10    
    11     // 清空cell背景色
    12     cell.backgroundColor = [UIColor clearColor];
    13    
    14     return cell;
    15 }
     
    c.设置微博view继承UIImageView,设置image(就是为了拉伸背景图片)
     1 //  HVWStatusContentView.m
     2 - (instancetype)initWithFrame:(CGRect)frame {
     3     self = [super initWithFrame:frame];
     4    
     5     if (self) { // 初始化子控件开始
     6         // 设置背景图片
     7         self.image = [UIImage resizedImage:@"timeline_card_top_background"];
     8         self.highlightedImage = [UIImage resizedImage:@"timeline_card_top_background_highlighted"];
     9        
    10         // 初始化原创内容控件
    11         [self setupOriginalView];
    12        
    13         // 初始化转发内容控件
    14         [self setupRetweetedView];
    15     }
    16    
    17     return self;
    18 }
     
    Image(156)
     
     
  • 相关阅读:
    SpringBoot-web场景-静态资源访问 & 欢迎页支持 & 自定义Favicon & 静态资源配置原理
    SpringBoot配置文件yaml文件的用法 & 自定义类绑定的配置提示
    设置 TabBarItem 选中时的图片及文字颜色
    iOS 9 使用HTTP的方法
    php单双引号嵌套解决方案
    github desktop项目版本控制
    数据库-内 | 左| 右| 全连接
    05_总结一下,以软件开发周期说明不同的测试使用
    04_用户需求 自己产品 竞争对手产品关系
    03_P52 课后作业
  • 原文地址:https://www.cnblogs.com/hellovoidworld/p/4311072.html
Copyright © 2020-2023  润新知