ios 淘宝评论详情、朋友圈布局masony实现
最近做项目,用到了类似于淘宝的朋友圈的功能,然后自己抽出了一个小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实现的更多相关文章
- iOS app url scheme跳转到淘宝商品详情页 唤醒app
最近涉及的一个业务,在app内的一个广告,点击打开webView,加载的是一个淘宝商品详情页,效果是打开该webView自动跳转至淘宝对应的页面,同时在自己的app仍然加载页面,点击评论等也同样能跳转 ...
- Python天猫淘宝评论爬虫
说明 由于Github 打包的exe某些文件上传被.gitignore了,所以不提供windows二进制包 https://github.com/hunterhug/taobaocomment 一个抓 ...
- 仿淘宝商品详情页上拉弹出新ViewController
新项目就要开始做了,里面有购物那块,就试着先把淘宝商品详情页的效果做了一下. 1.需求 1.第一次上拉时,A视图拉到一定距离将视图B从底部弹出,A视图也向上 2.显示B视图时下拉时,有刷新效果,之后将 ...
- Vue实现仿淘宝商品详情属性选择的功能
Vue实现仿淘宝商品详情属性选择的功能 先看下效果图:(同个属性内部单选,属性与属性之间可以多选) 主要实现过程: 所使用到的数据类型是(一个大数组里面嵌套了另一个数组)具体格式如下: attrA ...
- python3抓取淘宝评论内容
好久没有写爬虫了,今天研究了下淘宝商品评论的内容. 一开始用最简单的方法,挂代理,加请求头,对网页请求,是抓不到数据的,在网上找了一些相关文章,也基本已经过时了,就是网站逻辑有改动,用旧的方法是抓不到 ...
- Android开发案例 - 淘宝商品详情
所有电商APP的商品详情页面几乎都是和淘宝的一模一样(见下图): 采用上下分页的模式 商品基本参数 & 选购参数在上页展示 商品图文详情等其他信息放在下页展示 知识要点 垂直方向的ViewPa ...
- 抓取天猫和淘宝的详情页图片|Golang
taobao.go package main import ( "crypto/md5" "encoding/hex" "fmt" &quo ...
- Android开发案例 - 淘宝商品详情【转】
http://erehmi.cnblogs.com/ 所有电商APP的商品详情页面几乎都是和淘宝的一模一样(见下图): 采用上下分页的模式 商品基本参数 & 选购参数在上页展示 商品图文详情等 ...
- 一篇文章教会你用Python爬取淘宝评论数据(写在记事本)
[一.项目简介] 本文主要目标是采集淘宝的评价,找出客户所需要的功能.统计客户评价上面夸哪个功能多,比如防水,容量大,好看等等. 很多人学习python,不知道从何学起.很多人学习python,掌握了 ...
随机推荐
- 02 Vue指令
Vue指令 1.文本相关指令 <div id="app"> <!-- 插值表达式 --> <p>{{ msg }}</p> < ...
- DVWA学习记录 PartⅧ
Weak Session IDs 1. 题目 用户访问服务器的时候,为了区别多个用户,服务器都会给每一个用户分配一个 session id .用户拿到 session id 后就会保存到 cookie ...
- Java String:字符串常量池(转)
作为最基础的引用数据类型,Java 设计者为 String 提供了字符串常量池以提高其性能,那么字符串常量池的具体原理是什么? 字符串常量池的设计思想是什么? 字符串常量池在哪里? 如何操作字符串常量 ...
- web 部署专题(九):Nginx 前后端分离中csrf_token 认证的实现
1. 思路 参考:https://stackoverflow.com/questions/20826201/simple-csrf-protection-using-nginx-alone?r=Sea ...
- Django之重写用户模型
django——重写用户模型 Django内建的User模型可能不适合某些类型的项目.例如,在某些网站上使用邮件地址而不是用户名作为身份的标识可能更合理. 1.修改配置文件,覆盖默认的User模型 D ...
- spring security简单登录的认证
一.思路 1.先导入相关配置(使用spring security校验之后,登录拦截的配置) 2.创建一个 WebSecurityConfig 继承 WebSecurityConfigurerAdapt ...
- spring boot实现简单的登录拦截
一.思路 1.在pom.xml导入相关包 2.先写个简单的认证适配器(WebSecurityConfig extends WebSecurityConfigurerAdapter),登录拦截后就会跳转 ...
- Java8——Stream流
Stream是数据渠道,用于操作集合.数组等生成的元素序列. Stream操作的三个步骤: 创建Stream 中间操作 终止操作 一.获取stream的四种方式 通过collection系列集合的st ...
- MySQL数据库---库的操作
MySQL数据库中,以库,表,记录的形式管理所有的数据,安装MySQL数据库的服务器上可以包含多个库,一个库中包含多张表,一张表中包含多条记录.库对应的是文件系统中文件夹的概念,表对应的是文件的概念, ...
- Puppeteer爬虫实战(一)
Puppeteer 爬虫技术实践 信息简介 Puppeteer是Chrome开发团队发布的一个通过Chrome DevTool Protocol来控制浏览器Chrome(下文若无显式称呼Chromiu ...