計算文本和圖片的高度

-(CGFloat)getHeight
{
    CGFloat AllHeight = 0;
    if(![self.diary_content isEqualToString:@""]){
        CGSize size = [TextFrame textStr:self.diary_content andFont:15 andSize:CGSizeMake(SCREEN_WIDTH-80, MAXFLOAT)];
        AllHeight+=size.height;
    }
    float b  = self.images.count/3.0;
    NSInteger b1 = self.images.count/3;
    if(b!=b1){
        b1+=1;
    }
    AllHeight+=(b1*(SCREEN_WIDTH/4-10))+(b1*10);
    AllHeight+=50;
    if(AllHeight<=120){
        AllHeight=120;
        return AllHeight;
    }else{
        return AllHeight;
    }
    

}


self.diary_content 是文本內容


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章