首页 技术 正文
技术 2022年11月21日
0 收藏 724 点赞 2,384 浏览 18445 个字

github: https://github.com/hellovoidworld/HVWWeibo
A.cell的frame模型设计1.需求每个cell都有一个frame实例引用frame模型用来存储数据模型、设置子控件位置尺寸 2.思路frame模型同时包含了数据模型和子控件的frame实例引用跟view设计一样,也是采用分层设计每个view都有一个自己的frame模型 view层次:[iOS微博项目 – 4.1] – cell的frame模型 每个view对应一个frame:[iOS微博项目 – 4.1] – cell的frame模型 3.实现(1)view[iOS微博项目 – 4.1] – cell的frame模型 

 //
// 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模型[iOS微博项目 – 4.1] – cell的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模型  

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898