iOS单元格高度计算
// Created by mac on 16/6/29.
// Copyright © 2016年 zcc. All rights reserved.
// #import "HotCellHeight.h"
#import "UIViewExt.h"
#import "CommonalityH.h"
#define kTextWidth (kScreenWidth-20) //文字宽度
#define GAP 5 @implementation HotCellHeight
- (void)setHotModel:(HotModel *)hotModel{ _hotModel = hotModel;
//计算高度 [self countHeight]; }
#pragma mark 计算高度
- (void)countHeight{
CGFloat audiofloat = 0;
CGFloat imgfloat = 0;
CGFloat countHeight = 0;
_Height = 0; //计算头像 位置 _avatarFrame = CGRectMake(GAP, GAP, 30, 30);
countHeight += _avatarFrame.size.height + GAP * 2 ;
//用户名称位置
_user_NameFrame = CGRectMake(CGRectGetMaxX(_avatarFrame)+GAP, GAP, kScreenWidth - 30 - GAP * 2, 30); //计算线的位置 _wireFrame = CGRectMake(GAP, CGRectGetMaxY(_avatarFrame) + GAP,kScreenWidth - GAP*2 , 6); countHeight += _wireFrame.size.height + GAP; //计算图片位置
if(_hotModel.post_img == nil){ imgfloat = CGRectGetMaxY(_wireFrame);
}else{ _imgFrame = CGRectMake(GAP, CGRectGetMaxY(_wireFrame)+ GAP, kScreenWidth - GAP*2 ,kScreenWidth - GAP*2); countHeight += _imgFrame.size.height + GAP; imgfloat = CGRectGetMaxY(_imgFrame);
}
//计算文本位置 NSDictionary *dic = @{
NSFontAttributeName :
[UIFont fontWithName:@"FZLTCXHJW--GB1-0" size:15]
,
NSForegroundColorAttributeName :[UIColor blackColor] };
CGSize maximumLabelSize = CGSizeMake(kTextWidth, 120);
CGRect zFrame = [_hotModel.content boundingRectWithSize:maximumLabelSize options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil]; _contentFrame = CGRectMake(10, imgfloat + GAP, kTextWidth, zFrame.size.height); countHeight += _contentFrame.size.height + GAP ; //计算歌曲(背景)区域图片 if(_hotModel.post_audio == nil){ audiofloat = CGRectGetMaxY(_contentFrame); }else{ _backAudioFrame = CGRectMake(GAP, CGRectGetMaxY(_contentFrame)+ GAP, kScreenWidth-GAP*2, 36); //计算歌曲图片
_audioFrame = CGRectMake(GAP+3, CGRectGetMinY(_backAudioFrame)+3, 30, 30); audiofloat = CGRectGetMaxY(_backAudioFrame);
countHeight += _backAudioFrame.size.height + GAP ; //歌曲名称位置
_song_nameFrame = CGRectMake(CGRectGetMaxX(_audioFrame)+3, CGRectGetMinY(_backAudioFrame)+3,kScreenWidth - GAP + 3 + 3 + 30, 15); _artistFrame = CGRectMake(CGRectGetMaxX(_audioFrame)+3, CGRectGetMinY(_backAudioFrame)+3 + 15, kScreenWidth - GAP + 3 + 3 + 30, 15);
_countSongFrame = CGRectMake(CGRectGetMaxX(_backAudioFrame) - 40, CGRectGetMinY(_backAudioFrame)+3, 40, 30); _buttonLucencyFrame = _backAudioFrame;
} //计算更新时间位置 _downFrame = CGRectMake(GAP*2, audiofloat + GAP, kScreenWidth/2, 20); countHeight += _downFrame.size.height + GAP * 2; //背景大小位置 _backFrame = CGRectMake(0, 0, kScreenWidth, countHeight); _Height = countHeight; //不计算高度 计算位置 CGFloat wfloat = kScreenWidth/7;
//点赞图片位置
_vote_countImgFrame = CGRectMake(wfloat * 4.0 , audiofloat + GAP, 20, 20);
//评论图片
_comment_countImgFrame = CGRectMake(wfloat * 5.0 , audiofloat + GAP, 20, 20);
//分享图片
_shareImgFrame = CGRectMake(wfloat * 6.0 +10 , audiofloat + GAP, 20, 20);
//点赞数量
_vote_countFrame = CGRectMake(wfloat * 4.0 +25 , audiofloat + GAP, 30, 20);
//评论数量
_comment_countFrame = CGRectMake(wfloat * 5.0 +25 , audiofloat + GAP, 30, 20);
}
@end
.h
//
// Created by mac on 16/6/29.
// Copyright © 2016年 zcc. All rights reserved.
// #import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "HotModel.h"
@interface HotCellHeight : NSObject
@property(nonatomic,assign)CGRect avatarFrame;//头像
@property(nonatomic,assign)CGRect wireFrame;//线
@property(nonatomic,assign)CGRect imgFrame;//
@property(nonatomic,assign)CGRect contentFrame;//文本
@property(nonatomic,assign)CGRect audioFrame;//音乐图片高度
@property(nonatomic,assign)CGRect backAudioFrame;//区域音乐图片高度
@property(nonatomic,assign)CGRect downFrame;//更新时间
@property(nonatomic,assign)CGRect backFrame;//背景图片大小 @property(nonatomic,assign)CGFloat Height;//单元格总高度
@property(nonatomic,copy)HotModel *hotModel;//数据 @property(nonatomic,assign)CGRect user_NameFrame;//用户名
@property(nonatomic,assign)CGRect song_nameFrame;//歌名
@property(nonatomic,assign)CGRect artistFrame;//艺术家名称
@property(nonatomic,assign)CGRect countSongFrame;//歌曲数量
@property(nonatomic,assign)CGRect vote_countImgFrame;//点赞图片
@property(nonatomic,assign)CGRect comment_countImgFrame;//评论图片
@property(nonatomic,assign)CGRect shareImgFrame;//分享
@property(nonatomic,assign)CGRect vote_countFrame;//点赞数量
@property(nonatomic,assign)CGRect comment_countFrame;//评论数量 @property(nonatomic,assign)CGRect buttonLucencyFrame;//透明button的大小
@end
iOS单元格高度计算的更多相关文章
- iOS开发——Autolayout下动态调整单元格高度
情景描述: 有时候我们希望更新某一个单元格的数据,通常的做法是使用reloadData方法更新整个单元格.但是对一些情况是不适用的或者说实现起来比较麻烦.比如说这种简单的"点开"一 ...
- 【POI xls Java map】使用POI处理xls 抽取出异常信息 --java1.8Group by ---map迭代 -- 设置单元格高度
代码处理逻辑: 代码流程: 1.首先需要创建一个实体 用来存储 相关信息 package com.sxd.test.unusualName; public class NameEntity { pri ...
- [Xcode 实际操作]五、使用表格-(2)设置UITableView单元格高度
目录:[Swift]Xcode实际操作 本文将演示如何制作一个自定义行高的表格视图 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import UIKit //首 ...
- CSS开发技巧(二):表格合并边框后的单元格宽度计算
前言: 分离边框模型和合并边框模型是表格的两种模型,它通过以下属性确定: border-collapse:separate(默认值) | collapse | inherit 当采用分离边框模型时,表 ...
- Apach POI 如何拿到有公式的单元格,计算结果
public static void getFormulaCellValue(){ FileInputStream fis = new FileInputStream("c:/temp/te ...
- NPOI 图片在单元格等比缩放且居中显示
NPOI导出的图片默认是在单元格左上方,这使得图片在单元格显示得很难看.居中,且等比缩放,才是图片在单元格上的完美展示. /// <summary> /// 图片在单元格等比缩放居中显示 ...
- Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行
Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行 模版格式,图格式是最简单的格式,但实际效果不是这种,实际效果图如图2 图2 ,注意看红色部分,一对一是正常的,但是有一对多的订单 ...
- 优化UITableViewCell高度计算的那些事
优化UITableViewCell高度计算的那些事 我是前言 这篇文章是我和我们团队最近对 UITableViewCell 利用 AutoLayout 自动高度计算和 UITableView 滑动优化 ...
- 优化UITableViewCell高度计算的那些事(RunLoop)
这篇总结你可以读到: UITableView高度计算和估算的机制 不同iOS系统在高度计算上的差异 iOS8 self-sizing cell UITableView+FDTemplateLayout ...
随机推荐
- ".NET Compact Framework v2.0 could not be found."
参考: http://blog.csdn.net/godcyx/article/details/7348431 问题原因: That's a known issue where VS can't di ...
- 【TIP】已经上架的app在AppStore上搜不到的解决办法
相信很多人都遇到过这个问题,天天刷iTunes connect,终于发现app已经上架了,兴奋的跑过去告诉老板,老板说好,大家都装一个吧!然后大家过来问你怎么搜不到,老板看你都是一副这个表情: 这 ...
- C++11智能指针读书笔记;
智能指针是一个类对象,而非一个指针对象. 原始指针:通过new建立的*指针 智能指针:通过智能指针关键字(unique_ptr, shared_ptr ,weak_ptr)建立的指针 它的一种通用实现 ...
- maven学习(上)- 基本入门用法
一.下载及安装 1.1 下载maven 3.1.1 先到官网http://maven.apache.org/download.cgi 下载最新版本(目前是3.1.1 ),下载完成后,解压到某个目录(本 ...
- Date、Calender类及日期和字符串转换
Calendar是一个抽象类,抽象类java.util.Calendar 不可以通过new来获取一个实例,可以通过类方法getinstance()获取此类型的一个通用的对象 ①用法: Calendar ...
- 剑指Offer-【面试题04:替换空格】
package com.cxz.question4; /* * 请实现一个函数,把字符串中的每个空格替换成"%20",例如"We are happy.",则输出 ...
- RAC+asm通过rman恢复到单实例+asm
1.恢复参数文件,并修改参数文件 参数文件指名几个最简单的就行,我的参数文件如下: 2.恢复控制文件,并启动数据库到mount 如果是把备份集从别的服务器拷贝到本地恢复的服务器的目录,使用下面的语句指 ...
- [UWP]使用AdaptiveTrigger实现自适应布局
这篇博客将介绍如何在UWP开发中使用AdaptiveTrigger实现自适应布局. 场景1:窗体宽度大于800时,窗体背景色为绿色,窗体在0到800之间为蓝色. XAML Code: <Grid ...
- 关于 Dictionary<string,string>,和List<T>在View的使用
在MVC中Dictionary<string,string>如何应用到View页面中呢,例: <input type="text" name=key value= ...
- 第三十三篇:使用uiresImporter生成uires.idx及skin.xml
在SOUI中,使用uires.idx这个文件来记录程序中使用的所有资源文件. 此外绘制对象(ISkinObj)则一般放在skin.xml中描述. 要向一个界面中增加一个新的图片,在没有uiresImp ...