码迷,mamicode.com
首页 > 其他好文 > 详细

聊天两边的窗口高度的设置

时间:2015-05-14 00:40:25      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:

UILabel *left = [[UILabel alloc] init];
    
    left.text = @" Sent when the application is about to move from active to inactive state.";
    
    left.backgroundColor = [UIColor blueColor];
    
    //每个label宽200
    UIFont *font = left.font;
    NSString *content = left.text;
    
    CGSize realSize = [content sizeWithFont:font constrainedToSize:CGSizeMake(200, 1000)];
    
    left.frame = CGRectMake(10, 30, realSize.width, realSize.height);
    left.numberOfLines = 0;
    left.layer.cornerRadius = 10;
    left.clipsToBounds = YES;
    [self.window addSubview:left];
    

    
    UILabel *right = [[UILabel  alloc] init];
    
    right.text = @"Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates";
    
    right.backgroundColor  = [UIColor redColor];
    //计算高度,宽度200
    font = right.font;
    content = right.text;
    
    realSize = [content sizeWithFont:font constrainedToSize:CGSizeMake(200, 1000)];
    
    CGFloat leftMaxY = CGRectGetMaxY(left.frame);
    
    right.frame = CGRectMake(320 - realSize.width - 10, leftMaxY + 20, realSize.width, realSize.height);
    
    right.numberOfLines = 0;
    
    right.layer.cornerRadius = 10;
    right.clipsToBounds = YES;
    
    [self.window addSubview:right];

 

聊天两边的窗口高度的设置

标签:

原文地址:http://www.cnblogs.com/wlsky/p/4502070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!