最近做项目,用到了类似于淘宝的朋友圈的功能,然后自己抽出了一个小demo,与大家分享

介绍:用的是masony布局的cell这样的话,文本,以及图片可以自适应,不用人工再去计算高度,很方便。

注:该demo不涉及交互回复评论哦,只有展示的功能

给大家看一下图片效果:

下边贴上核心代码:

#import "AC_FriendCircleCell.h"

@interface AC_FriendCircleCell()
@property (nonatomic,strong)UIImageView *headIMG;
@property (nonatomic,strong)UILabel *nameL;
@property (nonatomic,strong)UILabel *timeL;
@property (nonatomic,strong)UILabel *introL;
@property (nonatomic,strong)UIView *imgs;
@property (nonatomic,strong)UIView *replyView;
@property (nonatomic,strong)UILabel *replayL;
@property (nonatomic,strong)UILabel *replyContent; //重要!!!!
@property (nonatomic,strong)id bottimView;//记录最下边的一个view
@property MASConstraint *midMasContraint;//记录暂存中间可能是最后一个的约束、 @end

  

初始化:

#pragma mark - 创建页面
- (void)createUI{
_headIMG = [[UIImageView alloc]init];
_timeL = [[UILabel alloc]init];
_nameL = [[UILabel alloc]init]; _introL = [[UILabel alloc]init];
_introL.numberOfLines = 0; _imgs = [[UIView alloc]init]; _replyView = [[UIView alloc]init];
_replyView.backgroundColor = RGBColor(240, 240, 240);
_replyView.clipsToBounds = YES;
_replayL = [[UILabel alloc]init];
_replayL.text = @"回复内容:";
_replayL.textColor = RGBColor(110, 110, 110);
_replyContent = [[UILabel alloc]init];
_replyContent.numberOfLines = 0;
[self.contentView addSubview:_headIMG];
[self.contentView addSubview:_timeL];
[self.contentView addSubview:_nameL]; [self.contentView addSubview:_introL]; [self.contentView addSubview:_imgs]; [self.contentView addSubview:_replyView];
[_replyView addSubview:_replayL];
[_replyView addSubview:_replyContent]; //设置约束 给不需要变化的部分设置约束
[_headIMG mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_offset(15).priorityHigh();
make.left.mas_offset(15);
make.height.mas_offset(50);
make.width.mas_offset(50);
}];
_headIMG.layer.cornerRadius = 25;
_headIMG.layer.masksToBounds = YES; [_nameL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.headIMG.mas_right).offset(15);
make.right.mas_offset(-15);
make.height.mas_offset(50/2);
make.top.mas_equalTo(self.headIMG.mas_top).priorityHigh();
}]; [_timeL mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameL.mas_left);
make.right.mas_equalTo(self.nameL.mas_right);
make.height.mas_equalTo(self.nameL.mas_height);
make.top.mas_equalTo(self.nameL.mas_bottom);
}]; }

  设置内容并更新masoney

 //对最后一个控件进行设置约束
[self.midMasContraint uninstall]; if (self.bottimView == self.introL) {
[self.introL mas_updateConstraints:^(MASConstraintMaker *make) {
self.midMasContraint = make.bottom.mas_offset(-);
}];
}else if (self.bottimView == self.imgs) {
[self.imgs mas_updateConstraints:^(MASConstraintMaker *make) {
self.midMasContraint = make.bottom.mas_offset(-);
}];
}else if (self.bottimView == self.replyView) {
[self.replyView mas_updateConstraints:^(MASConstraintMaker *make) {
self.midMasContraint = make.bottom.mas_offset(-);
}];
}

对指定的view进行更新

//设置评论内容
- (void)setIntro:(UIView*)lastView andContent:(NSString*)content{
[_introL mas_remakeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.headIMG.mas_left);
make.right.mas_equalTo(self.nameL.mas_right);
make.top.mas_equalTo(lastView.mas_bottom).offset().priorityHigh();
}]; _bottimView = _introL;
}

如法炮制,都加上便可以实现上述效果了。

ios 淘宝评论详情、朋友圈布局masony实现的更多相关文章

  1. iOS app url scheme跳转到淘宝商品详情页 唤醒app

    最近涉及的一个业务,在app内的一个广告,点击打开webView,加载的是一个淘宝商品详情页,效果是打开该webView自动跳转至淘宝对应的页面,同时在自己的app仍然加载页面,点击评论等也同样能跳转 ...

  2. Python天猫淘宝评论爬虫

    说明 由于Github 打包的exe某些文件上传被.gitignore了,所以不提供windows二进制包 https://github.com/hunterhug/taobaocomment 一个抓 ...

  3. 仿淘宝商品详情页上拉弹出新ViewController

    新项目就要开始做了,里面有购物那块,就试着先把淘宝商品详情页的效果做了一下. 1.需求 1.第一次上拉时,A视图拉到一定距离将视图B从底部弹出,A视图也向上 2.显示B视图时下拉时,有刷新效果,之后将 ...

  4. Vue实现仿淘宝商品详情属性选择的功能

    Vue实现仿淘宝商品详情属性选择的功能 先看下效果图:(同个属性内部单选,属性与属性之间可以多选) 主要实现过程: 所使用到的数据类型是(一个大数组里面嵌套了另一个数组)具体格式如下:   attrA ...

  5. python3抓取淘宝评论内容

    好久没有写爬虫了,今天研究了下淘宝商品评论的内容. 一开始用最简单的方法,挂代理,加请求头,对网页请求,是抓不到数据的,在网上找了一些相关文章,也基本已经过时了,就是网站逻辑有改动,用旧的方法是抓不到 ...

  6. Android开发案例 - 淘宝商品详情

    所有电商APP的商品详情页面几乎都是和淘宝的一模一样(见下图): 采用上下分页的模式 商品基本参数 & 选购参数在上页展示 商品图文详情等其他信息放在下页展示 知识要点 垂直方向的ViewPa ...

  7. 抓取天猫和淘宝的详情页图片|Golang

    taobao.go package main import ( "crypto/md5" "encoding/hex" "fmt" &quo ...

  8. Android开发案例 - 淘宝商品详情【转】

    http://erehmi.cnblogs.com/ 所有电商APP的商品详情页面几乎都是和淘宝的一模一样(见下图): 采用上下分页的模式 商品基本参数 & 选购参数在上页展示 商品图文详情等 ...

  9. 一篇文章教会你用Python爬取淘宝评论数据(写在记事本)

    [一.项目简介] 本文主要目标是采集淘宝的评价,找出客户所需要的功能.统计客户评价上面夸哪个功能多,比如防水,容量大,好看等等. 很多人学习python,不知道从何学起.很多人学习python,掌握了 ...

随机推荐

  1. 使用Python进行XML解析

    XML 指可扩展标记语言(eXtensible Markup Language),常被设计用来传输和存储数据. 在进行医学图像标注时,我们常使用XML格式文件来存储标注,以下展示了使用Python来提 ...

  2. javascript基础(四): 操作表单

    表单是什么?form-----DOM树 文本框----text 下拉框----select 单选框----radio 多选框----checkbox 隐藏域----hidden 密码框----pass ...

  3. 数据可视化之DAX篇(六) 利用ISINSCOPE函数,轻松按层级计算占比

    https://zhuanlan.zhihu.com/p/70590683 关于占比,之前有篇文章(利用ALL和ALLSELECTED灵活计算占比)详细介绍了各种情况下占比的度量值. 经星友咨询,还有 ...

  4. linux专题(七):账号管理

    http://dwz.date/UDf 简介 Linux系统是一个多用户多任务的分时操作系统,任何一个要使用系统资源的用户,都必须首先向系统管理员申请一个账号,然后以这个账号的身份进入系统. 用户的账 ...

  5. Ethical Hacking - Web Penetration Testing(12)

    XSS VULNS XSS - CROSS SITE SCRIPTING VULNS Allow an attacker to inject javascript code into the page ...

  6. 从Excel(CSV)文件导入数据到Oracle

    步骤: 1.准备数据:在excel中构造出需要的数据2.将excel中的数据另存为文本文件(有制表符分隔的)3.将新保存到文本文件中的数据导入到pl*sql中在pl*sql中选择tools--text ...

  7. 洛谷P2365/5785 任务安排 题解 斜率优化DP

    任务安排1(小数据):https://www.luogu.com.cn/problem/P2365 任务安排2(大数据):https://www.luogu.com.cn/problem/P5785 ...

  8. 写给.NET开发者的Python教程(二):基本类型和变量

    从本文开始,我们就要正式了解Python的语法特性了,这章主要介绍基本类型和变量,开始之前先介绍下Python中的标准输入输出. 标准输入输出 前文举过TwoSum问题的例子,但是没有讲到标准输入输出 ...

  9. CentOS7上安装Hadoop

    设置sshssh-keygen -t rsa -P ''cat id_rsa.pub >> authorized_keys 查看slaves节点的id_rsa.pub文件,将文件内容复制到 ...

  10. 常用CSS颜色表

    1.16进制的CSS颜色代码 > http://www.jsjtt.com/webkaifa/HTML/65.html