A.cell的frame模型设计
1.需求
每个cell都有一个frame实例引用
frame模型用来存储数据模型、设置子控件位置尺寸
 
2.思路
frame模型同时包含了数据模型和子控件的frame实例引用
跟view设计一样,也是采用分层设计
每个view都有一个自己的frame模型
 
view层次:
 
每个view对应一个frame:
 
3.实现
(1)view
 
 //
// HVWStatusCell.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h>
#import "HVWStatusFrame.h" @interface HVWStatusCell : UITableViewCell /** frame */
@property(nonatomic, strong) HVWStatusFrame *statusFrame; /** 创建方法 */
+ (instancetype) cellWithTableView:(UITableView *)tableView; @end
 
 //
// HVWStatusCell.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusCell.h"
#import "HVWStatusContentView.h"
#import "HVWStatusToolbar.h" @interface HVWStatusCell() /** 微博内容控件 */
@property(nonatomic, weak) HVWStatusContentView *statusContentView; /** 微博工具条控件 */
@property(nonatomic, weak) HVWStatusToolbar *toolbar; @end @implementation HVWStatusCell /** 创建 */
+ (instancetype) cellWithTableView:(UITableView *)tableView {
static NSString *ID = @"HVWStatusCell";
HVWStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (nil == cell) {
cell = [[self alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
} return cell;
} /** 初始化 */
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { // 初始化子控件开始
// 初始化微博内容控件
[self setupStatusContentView]; // 初始化工具条控件 */
// [self setupToolbar];
} return self;
} /** 初始化微博内容控件 */
- (void) setupStatusContentView {
HVWStatusContentView *statusContentView = [[HVWStatusContentView alloc] init];
self.statusContentView = statusContentView;
[self.contentView addSubview:statusContentView];
} /** 初始化工具条控件 */
- (void) setupToolbar {
HVWStatusToolbar *toolbar = [[HVWStatusToolbar alloc] init];
self.toolbar = toolbar;
[self.contentView addSubview:toolbar];
} /** 初始化frame */
- (void)setStatusFrame:(HVWStatusFrame *)statusFrame {
_statusFrame = statusFrame; // 设置微博内容frame
self.statusContentView.contentFrame = statusFrame.contentFrame; // 设置工具条frame
self.toolbar.toolbarFrame = statusFrame.toolbarFrame;
} @end
 
 //
// HVWStatusContentView.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h>
#import "HVWStatusContentFrame.h" @interface HVWStatusContentView : UIView /** frame */
@property(nonatomic, strong) HVWStatusContentFrame *contentFrame; @end
 
 //
// HVWStatusContentView.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusContentView.h"
#import "HVWStatusOriginalView.h"
#import "HVWStatusRetweetedView.h" @interface HVWStatusContentView() /** 原创内容 */
@property(nonatomic, weak) HVWStatusOriginalView *originalView; /** 转发内容 */
@property(nonatomic, weak) HVWStatusRetweetedView *retweetedView; @end @implementation HVWStatusContentView - (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) { // 初始化子控件开始
// 初始化原创内容控件
[self setupOriginalView]; // 初始化转发内容控件
[self setupRetweetedView];
} return self;
} /** 初始化原创内容控件 */
- (void) setupOriginalView {
HVWStatusOriginalView *originalView = [[HVWStatusOriginalView alloc] init];
self.originalView = originalView;
[self addSubview:originalView];
} /** 初始化转发内容控件 */
- (void) setupRetweetedView {
HVWStatusRetweetedView *retweetedView = [[HVWStatusRetweetedView alloc] init];
self.retweetedView = retweetedView;
[self addSubview:retweetedView];
} /** 设置frame */
- (void)setContentFrame:(HVWStatusContentFrame *)contentFrame {
_contentFrame = contentFrame; // 原创微博frame
self.originalView.originalFrame = self.contentFrame.originalFrame; // 转发微博frame
self.retweetedView.retweetedFrame = self.contentFrame.retweetedFrame; // 设置自己的frame
self.frame = contentFrame.frame;
} @end
 
 //
// HVWStatusOriginalView.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h>
#import "HVWStatusOriginalFrame.h" @interface HVWStatusOriginalView : UIView /** frame */
@property(nonatomic, strong) HVWStatusOriginalFrame *originalFrame; @end
 
 //
// HVWStatusOriginalView.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusOriginalView.h"
#import "HVWStatus.h"
#import "HVWUser.h"
#import "UIImageView+WebCache.h" @interface HVWStatusOriginalView() /** 昵称 */
@property(nonatomic, weak) UILabel *nameLabel; /** 头像 */
@property(nonatomic, weak) UIImageView *iconView; /** 微博发表时间 */
@property(nonatomic, weak) UILabel *timeLabel; /** 微博来源 */
@property(nonatomic, weak) UILabel *sourceLabel; /** 微博文本内容 */
@property(nonatomic, weak) UILabel *textLabel; @end @implementation HVWStatusOriginalView /** 代码初始化方法 */
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) { // 初始化子控件开始
// 昵称
UILabel *nameLabel = [[UILabel alloc] init];
nameLabel.font = HVWStatusOriginalNameFont;
self.nameLabel = nameLabel;
[self addSubview:nameLabel]; // 头像
UIImageView *iconView = [[UIImageView alloc] init];
self.iconView = iconView;
[self addSubview:iconView]; // 发表时间
UILabel *timeLabel = [[UILabel alloc] init];
self.timeLabel = timeLabel;
[self addSubview:timeLabel]; // self.timeLabel.backgroundColor = [UIColor greenColor]; // 来源
UILabel *sourceLabel = [[UILabel alloc] init];
self.sourceLabel = sourceLabel;
[self addSubview:sourceLabel]; // self.sourceLabel.backgroundColor = [UIColor yellowColor]; // 正文
UILabel *textLabel = [[UILabel alloc] init];
self.textLabel = textLabel;
[self addSubview:textLabel]; // self.backgroundColor = [UIColor redColor];
} return self;
} /** 设置frame */
- (void)setOriginalFrame:(HVWStatusOriginalFrame *)originalFrame {
_originalFrame = originalFrame; HVWStatus *status = originalFrame.status;
HVWUser *user = status.user; // 设置控件frame
// 头像
self.iconView.frame = originalFrame.iconFrame;
[self.iconView setImageWithURL:[NSURL URLWithString:user.profile_image_url] placeholderImage:[UIImage imageWithNamed:@"avatar_default_small"]]; // 昵称
self.nameLabel.frame = originalFrame.nameFrame;
self.nameLabel.font = HVWStatusOriginalNameFont;
self.nameLabel.text = user.name; // 发表时间
self.timeLabel.frame = originalFrame.timeFrame;
self.timeLabel.font = HVWStatusOriginalTimeFont;
self.timeLabel.text = status.created_at; // 来源
self.sourceLabel.frame = originalFrame.sourceFrame;
self.sourceLabel.font = HVWStatusOriginalSourceFont;
self.sourceLabel.text = status.source; /* 由于“发表时间”随着时间推移会产生变化
* 每次都要重新计算“发表时间”和“来源”的frame
*/
// 发表时间
CGFloat timeX = self.nameLabel.frame.origin.x;
CGFloat timeY = CGRectGetMaxY(self.nameLabel.frame);
CGSize timeBoundSize = CGSizeMake(HVWScreenWidth - timeX, MAXFLOAT);
NSDictionary *timeBoundParam = @{NSFontAttributeName : HVWStatusOriginalTimeFont};
CGSize timeSize = [status.created_at boundingRectWithSize:timeBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:timeBoundParam context:nil].size;
self.timeLabel.frame = (CGRect){{timeX, timeY}, timeSize}; // 来源
CGFloat sourceX = CGRectGetMaxX(self.timeLabel.frame) + HVWStatusCellInset;
CGFloat sourceY = timeY;
CGSize sourceBoundSize = CGSizeMake(HVWScreenWidth - sourceX, MAXFLOAT);
NSDictionary *sourceBoundParam = @{NSFontAttributeName : HVWStatusOriginalSourceFont};
CGSize sourceSize = [status.source boundingRectWithSize:sourceBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:sourceBoundParam context:nil].size;
self.sourceLabel.frame = (CGRect){{sourceX, sourceY}, sourceSize}; // 正文
self.textLabel.frame = originalFrame.textFrame;
self.textLabel.font = HVWStatusOriginalTextFont;
// 设置自动换行
self.textLabel.numberOfLines = ;
self.textLabel.text = status.text; // 设置自己的frame
self.frame = originalFrame.frame;
} @end
 
 //
// HVWStatusRetweetedView.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h>
#import "HVWStatusRetweetedFrame.h" @interface HVWStatusRetweetedView : UIView /** frame */
@property(nonatomic, strong) HVWStatusRetweetedFrame *retweetedFrame; @end
 
 //
// HVWStatusRetweetedView.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusRetweetedView.h"
#import "HVWStatus.h"
#import "HVWUser.h" @interface HVWStatusRetweetedView() /** 昵称 */
@property(nonatomic, weak) UILabel *nameLabel; /** 微博文本内容 */
@property(nonatomic, weak) UILabel *textLabel; @end @implementation HVWStatusRetweetedView /** 代码初始化方法 */
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) { // 初始化子控件开始
// 昵称
UILabel *nameLabel = [[UILabel alloc] init];
nameLabel.font = HVWStatusOriginalNameFont;
self.nameLabel = nameLabel;
[self addSubview:nameLabel]; // 正文
UILabel *textLabel = [[UILabel alloc] init];
textLabel.font = HVWStatusRetweetedTextFont;
textLabel.numberOfLines = ; // 设置自动换行
self.textLabel = textLabel;
[self addSubview:textLabel]; self.backgroundColor = [UIColor grayColor];
} return self;
} /** 设置frame */
- (void)setRetweetedFrame:(HVWStatusRetweetedFrame *)retweetedFrame {
_retweetedFrame = retweetedFrame; HVWStatus *status = retweetedFrame.status; // 设置控件frame
// 昵称
self.nameLabel.frame = retweetedFrame.nameFrame;
self.nameLabel.text = [status retweetedName]; // 正文
self.textLabel.frame = retweetedFrame.textFrame;
self.textLabel.text = status.text; // 设置自己的frame
self.frame = retweetedFrame.frame;
} @end
 
 //
// HVWStatusToolbar.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <UIKit/UIKit.h>
#import "HVWStatusToolbarFrame.h" @interface HVWStatusToolbar : UIView /** frame */
@property(nonatomic, strong) HVWStatusToolbarFrame *toolbarFrame; @end
 
 //
// HVWStatusToolbar.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusToolbar.h" @implementation HVWStatusToolbar /** 代码自定义初始化方法 */
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame]; if (self) {
self.backgroundColor = [UIColor greenColor];
} return self;
} - (void)setToolbarFrame:(HVWStatusToolbarFrame *)toolbarFrame {
_toolbarFrame = toolbarFrame; // 设置自己的frame
self.frame = toolbarFrame.frame;
} @end
 
 
(2)frame模型
 
 //
// HVWStatusFrame.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h>
#import "HVWStatus.h"
#import "HVWStatusContentFrame.h"
#import "HVWStatusToolbarFrame.h" @interface HVWStatusFrame : NSObject #pragma mark - 数据模型
/** cell内微博数据 */
@property(nonatomic, strong) HVWStatus *status; #pragma mark - frame模型
/** 微博内容frame */
@property(nonatomic, strong) HVWStatusContentFrame *contentFrame; /** 工具条frame */
@property(nonatomic, strong) HVWStatusToolbarFrame *toolbarFrame; /** cell高度 */
@property(nonatomic, assign) CGFloat cellHeight; #pragma mark - 方法
/** 使用status数组包装一个statusFrame数组 */
+ (NSArray *) statusFramesWithStatuses:(NSArray *)statuses; @end
 
 //
// HVWStatusFrame.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusFrame.h"
#import "HVWStatusContentFrame.h"
#import "HVWStatusToolbarFrame.h" @implementation HVWStatusFrame /** 使用status数组包装一个statusFrame数组 */
+ (NSArray *) statusFramesWithStatuses:(NSArray *)statuses {
NSMutableArray *statusFrameArray = [NSMutableArray array];
for (HVWStatus *status in statuses) {
HVWStatusFrame *statusFrame = [[HVWStatusFrame alloc] init];
statusFrame.status = status;
[statusFrameArray addObject:statusFrame];
}
return statusFrameArray;
} /** 加载数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; // 设置子控件frame
// 微博内容frame
HVWStatusContentFrame *contentFrame = [[HVWStatusContentFrame alloc] init];
self.contentFrame = contentFrame;
contentFrame.status = status; // 工具条frame
HVWStatusToolbarFrame *toolbarFrame = [[HVWStatusToolbarFrame alloc] init];
self.toolbarFrame = toolbarFrame;
toolbarFrame.status = status;
CGRect tbFrame = toolbarFrame.frame;
tbFrame.origin.y = CGRectGetMaxY(contentFrame.frame); // cell高度
self.cellHeight = CGRectGetMaxY(tbFrame);
} @end
 
 //
// HVWStatusContentFrame.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h>
#import "HVWStatusOriginalFrame.h"
#import "HVWStatusRetweetedFrame.h"
#import "HVWStatus.h" @interface HVWStatusContentFrame : NSObject #pragma mark - frame模型
/** 原创微博frame */
@property(nonatomic, strong) HVWStatusOriginalFrame *originalFrame; /** 转发微博frame */
@property(nonatomic, strong) HVWStatusRetweetedFrame *retweetedFrame; /** 自己的frame */
@property(nonatomic, assign) CGRect frame; #pragma mark - 数据模型
/** 微博数据 */
@property(nonatomic, strong) HVWStatus *status; @end
 
 //
// HVWStatusContentFrame.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusContentFrame.h"
#import "HVWStatusOriginalFrame.h"
#import "HVWStatusRetweetedFrame.h" @implementation HVWStatusContentFrame /** 加载微博数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; // 设置控件frame
// 原创微博
HVWStatusOriginalFrame *originalFrame = [[HVWStatusOriginalFrame alloc] init];
self.originalFrame = originalFrame;
originalFrame.status = status; // 转发微博
CGFloat contentHeight = ;
if (self.status.retweeted_status) { // 当转发了微博的时候
HVWStatusRetweetedFrame *retweetedFrame = [[HVWStatusRetweetedFrame alloc] init];
retweetedFrame.status = status.retweeted_status; // 设置frame
CGRect retFrame = retweetedFrame.frame;
retFrame.origin.y = CGRectGetMaxY(originalFrame.frame); retweetedFrame.frame = retFrame;
self.retweetedFrame = retweetedFrame; contentHeight = CGRectGetMaxY(retFrame);
} else {
contentHeight = CGRectGetMaxY(originalFrame.frame);
} // 自己的frame
CGFloat contentX = ;
CGFloat contentY = ;
CGFloat contentWidth = HVWScreenWidth;
self.frame = CGRectMake(contentX, contentY, contentWidth, contentHeight);
} @end
 
 //
// HVWStatusOriginalFrame.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h>
#import "HVWStatus.h" @interface HVWStatusOriginalFrame : NSObject #pragma mark - frame模型
/** 自己的frame */
@property(nonatomic, assign) CGRect frame; /** 昵称 */
@property(nonatomic, assign) CGRect nameFrame; /** 正文 */
@property(nonatomic, assign) CGRect textFrame; /** 来源 */
@property(nonatomic, assign) CGRect sourceFrame; /** 发表时间 */
@property(nonatomic, assign) CGRect timeFrame; /** 头像 */
@property(nonatomic, assign) CGRect iconFrame; #pragma mark - 数据模型
/** 微博数据 */
@property(nonatomic, strong) HVWStatus *status; @end
 
 //
// HVWStatusOriginalFrame.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusOriginalFrame.h" @implementation HVWStatusOriginalFrame /** 加载微博数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; // 设置控件frame
// 头像
CGFloat iconX = HVWStatusCellInset;
CGFloat iconY = HVWStatusCellInset;
CGFloat iconWidth = ;
CGFloat iconHeight = ;
self.iconFrame = CGRectMake(iconX, iconY, iconWidth, iconHeight); // 昵称
CGFloat nameX = CGRectGetMaxX(self.iconFrame) + HVWStatusCellInset;
CGFloat nameY = iconY; HVWUser *user = status.user;
CGSize nameBoundSize = CGSizeMake(HVWScreenWidth - nameX, MAXFLOAT);
NSDictionary *nameBoundParam = @{NSFontAttributeName : HVWStatusOriginalNameFont};
CGSize nameSize = [user.name boundingRectWithSize:nameBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:nameBoundParam context:nil].size;
self.nameFrame = (CGRect){{nameX, nameY}, nameSize}; /** 由于发表时间会随着时间推移变化,所以不能在这里一次性设置尺寸
* 而“来源”的位置尺寸和“发表时间”有关联,所以一起移走
* 移动到view,每次加载“发表时间”、“来源”都要重新计算size
// 发表时间
CGFloat timeX = nameX;
CGFloat timeY = CGRectGetMaxY(self.nameFrame);
CGSize timeBoundSize = CGSizeMake(HVWScreenWidth - timeX, MAXFLOAT);
NSDictionary *timeBoundParam = @{NSFontAttributeName : HVWStatusOriginalTimeFont};
CGSize timeSize = [status.created_at boundingRectWithSize:timeBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:timeBoundParam context:nil].size;
self.timeFrame = (CGRect){{timeX, timeY}, timeSize}; // 来源
CGFloat sourceX = CGRectGetMaxX(self.timeFrame) + HVWStatusCellInset;
CGFloat sourceY = timeY;
CGSize sourceBoundSize = CGSizeMake(HVWScreenWidth - sourceX, MAXFLOAT);
NSDictionary *sourceBoundParam = @{NSFontAttributeName : HVWStatusOriginalSourceFont};
CGSize sourceSize = [status.source boundingRectWithSize:sourceBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:sourceBoundParam context:nil].size;
self.sourceFrame = (CGRect){{sourceX, sourceY}, sourceSize};
*/ // 正文
CGFloat textX = iconX;
CGFloat textY = CGRectGetMaxY(self.iconFrame);
CGSize textBoundSize = CGSizeMake(HVWScreenWidth - textX * , MAXFLOAT);
NSDictionary *textBoundParam = @{NSFontAttributeName : HVWStatusOriginalTextFont};
CGSize textSize = [status.text boundingRectWithSize:textBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:textBoundParam context:nil].size;
self.textFrame = (CGRect){{textX, textY}, textSize}; // 设置自己的frame
CGFloat x = ;
CGFloat y = ;
CGFloat width = HVWScreenWidth;
CGFloat height = CGRectGetMaxY(self.textFrame) + HVWStatusCellInset;
self.frame = CGRectMake(x, y, width, height);
} @end
 
 //
// HVWStatusRetweetedFrame.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h>
#import "HVWStatus.h" @interface HVWStatusRetweetedFrame : NSObject #pragma mark - frame模型
/** 自己的frame */
@property(nonatomic, assign) CGRect frame; /** 昵称 */
@property(nonatomic, assign) CGRect nameFrame; /** 正文 */
@property(nonatomic, assign) CGRect textFrame; #pragma mark - 数据模型
/** 微博数据 */
@property(nonatomic, strong) HVWStatus *status; @end
 
 //
// HVWStatusRetweetedFrame.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusRetweetedFrame.h" @implementation HVWStatusRetweetedFrame /** 加载微博数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; // 设置控件frame
// 昵称
CGFloat nameX = HVWStatusCellInset;
CGFloat nameY = HVWStatusCellInset;
CGSize nameBoundSize = CGSizeMake(HVWScreenWidth - nameX * , MAXFLOAT);
NSDictionary *nameBoundParam = @{NSFontAttributeName : HVWStatusOriginalNameFont};
CGSize nameSize = [[status retweetedName] boundingRectWithSize:nameBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:nameBoundParam context:nil].size;
self.nameFrame = (CGRect){{nameX, nameY}, nameSize}; // 正文
CGFloat textX = nameX;
CGFloat textY = CGRectGetMaxY(self.nameFrame);
CGSize textBoundSize = CGSizeMake(HVWScreenWidth - textX * , MAXFLOAT);
NSDictionary *textBoundParam = @{NSFontAttributeName : HVWStatusOriginalTextFont};
CGSize textSize = [status.text boundingRectWithSize:textBoundSize options:NSStringDrawingUsesLineFragmentOrigin attributes:textBoundParam context:nil].size;
self.textFrame = (CGRect){{textX, textY}, textSize}; // 设置自己的frame
CGFloat x = ;
CGFloat y = ;
CGFloat width = HVWScreenWidth;
CGFloat height = CGRectGetMaxY(self.textFrame) + HVWStatusCellInset;
self.frame = CGRectMake(x, y, width, height);
} @end
 
 //
// HVWStatusToolbarFrame.h
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import <Foundation/Foundation.h>
#import "HVWStatus.h" @interface HVWStatusToolbarFrame : NSObject #pragma mark - frame模型
/** 自己的frame */
@property(nonatomic, assign) CGRect frame; #pragma mark - 数据模型
/** 微博数据 */
@property(nonatomic, strong) HVWStatus *status; @end
 
 //
// HVWStatusToolbarFrame.m
// HVWWeibo
//
// Created by hellovoidworld on 15/2/12.
// Copyright (c) 2015年 hellovoidworld. All rights reserved.
// #import "HVWStatusToolbarFrame.h" @implementation HVWStatusToolbarFrame /** 加载数据 */
- (void)setStatus:(HVWStatus *)status {
_status = status; // 设计自己的frame
CGFloat x = ;
CGFloat y = ;
CGFloat width = HVWScreenWidth;
CGFloat height = ;
self.frame = CGRectMake(x, y, width, height);
} @end
 
 
 
 

[iOS微博项目 - 4.1] - cell的frame模型的更多相关文章

  1. [iOS微博项目 - 4.0] - 自定义微博cell

    github: https://github.com/hellovoidworld/HVWWeibo A.自定义微博cell基本结构 1.需求 创建自定义cell的雏形 cell包含:内容.工具条 内 ...

  2. [iOS微博项目 - 3.0] - 手动刷新微博

    github: https://github.com/hellovoidworld/HVWWeibo   A.下拉刷新微博 1.需求 在“首页”界面,下拉到一定距离的时候刷新微博数据 刷新数据的时候使 ...

  3. [iOS微博项目 - 4.5] - 每条微博的底部工具条

    github: https://github.com/hellovoidworld/HVWWeibo A.每条微博的底部工具条 1.需求 每条微博底部都有一个工具条 显示3个按钮:评论.转发.赞 按钮 ...

  4. [iOS微博项目 - 3.5] - 封装业务

    github: https://github.com/hellovoidworld/HVWWeibo   A.封装微博业务 1.需求 把微博相关业务(读取.写微博) 界面控制器不需要知道微博操作细节( ...

  5. [iOS微博项目 - 4.4] - 会员标识

    github: https://github.com/hellovoidworld/HVWWeibo A.会员标识 1.需求 给vip会员打上会员标识 不同等级的vip会员使用不同的标识 使用橙色作为 ...

  6. [iOS微博项目 - 4.3] - 设置每条微博边框样式

    github: https://github.com/hellovoidworld/HVWWeibo A.设置每条微博边框样式 1.需求 不需要分割线 每个微博之间留有一定的间隙   2.思路 直接设 ...

  7. [iOS微博项目 - 3.1] - 发微博界面

    github: https://github.com/hellovoidworld/HVWWeibo   A.发微博界面:自定义UITextView 1.需求 用UITextView做一个编写微博的输 ...

  8. [iOS微博项目 - 2.6] - 获取微博数据

    github: https://github.com/hellovoidworld/HVWWeibo   A.新浪获取微博API 1.读取微博API     2.“statuses/home_time ...

  9. [iOS微博项目 - 1.7] - 版本新特性

    A.版本新特性 1.需求 第一次使用新版本的时候,不直接进入app,而是展示新特性界面 github: https://github.com/hellovoidworld/HVWWeibo       ...

随机推荐

  1. 使用c++的cocos2d-x-3.0rc1程序公布apk

    (如今cocos2dx-x-3.0正式版已经出了.之前用的cocos2d-x-3.0rc1,就先用这个版本号吧) 0. 完毕C++项目 在cmd下使用cocos.py new命令,然后习惯性的在win ...

  2. iconv 解决乱码问题

    [root@NGINX-APACHE-SVN pro]# file 林.txt 林.txt: ISO-8859 text, with no line terminators #在LINUX下显示乱码 ...

  3. SQL业务审核与优化

    审核   什么是业务审核 类似与code review 评审业务Schema和SQL设计 偏重关注性能 是业务优化的主要入口之一           审核提前发现问题,进行优化           上 ...

  4. Django rest_framework 认证源码流程

    一.请求到来后,都要先执行dispatch方法 dispatch根据请求方式的不同触发get/post/put/delete等方法 注意,APIView中的dispatch方法有很多的功能 def d ...

  5. filter从web.xml读取config的时候中文编码问题

    首先,web.xml中不建议出现超出ASCII范围的字符 但是作为一点积累,简单举个例子如下,其核心代码就是new String(String.getBytes(charset_1), charset ...

  6. 在sql中根据成绩显示学生排名

    1.准备 create table newtable ( name ), yuwen ), shuxue ) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; , ); , ...

  7. phoenix系统创建语句

    CREATE TABLE SYSTEM."CATALOG"( TENANT_ID VARCHAR NULL, TABLE_SCHEM VARCHAR NULL, TABLE_NAM ...

  8. am335x gpio控制

    1.执行下面的命令,可以显示目前驱动已经申请到的IO状态 : $ mount -t debugfs debugfs /sys/kernel/debug  $ cat /sys/kernel/debug ...

  9. UCOS2_STM32移植详细过程(汇总)

    Ⅰ.概述 笔者发现一个问题,很多初学者,甚至很多工作一两年的人,他们有一种依赖的思想,就是希望从别处获取的软件代码不做任何修改,直接可以运行或者使用.笔者想说,实践才是检验真理的关键,实践才是掌握知识 ...

  10. Netty系列之Netty百万级推送服务设计要点(转)

    1. 背景 1.1. 话题来源 最近很多从事移动互联网和物联网开发的同学给我发邮件或者微博私信我,咨询推送服务相关的问题.问题五花八门,在帮助大家答疑解惑的过程中,我也对问题进行了总结,大概可以归纳为 ...