首页 > 其他 > 详细

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

时间:2015-05-14 00:40:05      阅读:222      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!