新浪微博开发之三十(转发微博frame)

来源:互联网 发布:企业 java用什么软件 编辑:程序博客网 时间:2024/06/06 03:59
//
//  MyweiboRetweetedFrame.h
//  新浪微博
//
//  Created by Jose on 15-4-20.
//  Copyright (c) 2015年 jose. All rights reserved.
//  转发微博frame


#import <Foundation/Foundation.h>
#import "UIView+Extension.h"
@class MyWeiboModel;


@interface MyweiboRetweetedFrame : NSObject
/** 转发微博的昵称 */
@property(nonatomic,assign)CGRect nameframe;
/** 转发微博正文 */
@property(nonatomic,assign)CGRect textframe;
/** 转发微博自己的frame */
@property(nonatomic,assign)CGRect retweetedframe;
/** 转发微博的数据 */
@property(nonatomic,strong)MyWeiboModel *retweetedweibo;

@end



**********************************************************************************************************************

************************************************************************************************************************

***********************************************************************************************************************

//
//  MyweiboRetweetedFrame.m
//  新浪微博
//
//  Created by Jose on 15-4-20.
//  Copyright (c) 2015年 jose. All rights reserved.
//


#import "MyweiboRetweetedFrame.h"
#import "MyWeiboModel.h"
#import "MyUserModel.h"
#import "Global.h"


@implementation MyweiboRetweetedFrame


-(void)setRetweetedweibo:(MyWeiboModel *)retweetedweibo{
    _retweetedweibo=retweetedweibo;
    
    //1.计算转发微博的昵称
    CGFloat namex=CellMargin;
    CGFloat namey=CellMargin;
    //在转发微博的昵称面前加上@
    NSString *name=[NSString stringWithFormat:@"@%@",self.retweetedweibo.user.name];
    CGSize  namesize=[name sizeWithFont:RetweetedName];
    self.nameframe=(CGRect){{namex,namey},namesize};
    
    
    //2.计算转发微博的正文
    CGFloat textx=CellMargin;
    CGFloat texty=CGRectGetMaxY(self.nameframe)+CellMargin;
    CGFloat maxw=ScreenBounds.size.width-2*CellMargin;
    CGSize maxsize=CGSizeMake(maxw, MAXFLOAT);
    CGSize textsize=[self.retweetedweibo.text sizeWithFont:RetweetedText constrainedToSize:maxsize];
    self.textframe=(CGRect){{textx,texty},textsize};
    
    //3.计算转发微博自己的frame
    CGFloat x=0;
    //y是原创微博的最大y值,默认是0
    CGFloat y=0;
    CGFloat w=ScreenBounds.size.width;
    CGFloat h=CGRectGetMaxY(self.textframe)+CellMargin;
    self.retweetedframe=CGRectMake(x, y, w, h);
}
@end

0 0
原创粉丝点击