UILabel高度自适应

        //活动内容(使用高度自适应)
        UILabel *content = [[UILabel alloc] initWithFrame:CGRectMake(30, 260, 0, 0)];
        [content setNumberOfLines:0];
        content.lineBreakMode = UILineBreakModeWordWrap;
        content.text = [[self.activityList objectAtIndex:i] objectForKey:@"text"];
        content.font = [UIFont fontWithName:@"Microsoft YaHei" size:10];
        CGSize size = CGSizeMake(300, 190);
        CGSize labelsize = [content.text sizeWithFont:content.font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
        [content setFrame:CGRectMake(30, 260, labelsize.width, labelsize.height)];
        content.backgroundColor = [UIColor clearColor];
        content.textColor = [GCCommonHelper colorForHex:@"535353"];
        [view addSubview:content];
        [content release];
posted @ 2012-09-25 07:27  FoxBabe  阅读(1143)  评论(0编辑  收藏  举报