IOS的水滴文件效果
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"weixin",@"name",@"微信团队欢迎你。很高兴你开启了微信生活,期待能为你和朋友们带来愉快的沟通体检。",@"content", nil];
NSDictionary *dict1 = [NSDictionary dictionaryWithObjectsAndKeys:@"rhl",@"name",@"hello",@"content", nil];
NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:@"rhl",@"name",@"0",@"content", nil];
NSDictionary *dict3 = [NSDictionary dictionaryWithObjectsAndKeys:@"weixin",@"name",@"谢谢反馈,已收录。",@"content", nil];
NSDictionary *dict4 = [NSDictionary dictionaryWithObjectsAndKeys:@"rhl",@"name",@"0",@"content", nil];
NSDictionary *dict5 = [NSDictionary dictionaryWithObjectsAndKeys:@"weixin",@"name",@"谢谢反馈,已收录。",@"content", nil];
NSDictionary *dict6 = [NSDictionary dictionaryWithObjectsAndKeys:@"rhl",@"name",@"大数据测试,长数据测试,大数据测试,长数据测试,大数据测试,长数据测试,大数据测试,长数据测试,大数据测试,长数据测试,大数据测试,长数据测试。",@"content", nil];
_resultArray = [NSMutableArray arrayWithObjects:dict,dict1,dict2,dict3,dict4,dict5,dict6, nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//泡泡文本
- (UIView *)bubbleView:(NSString *)text from:(BOOL)fromSelf withPosition:(int)position{
//计算大小
UIFont *font = [UIFont systemFontOfSize:14];
CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(180.0f, 20000.0f) lineBreakMode:NSLineBreakByWordWrapping];
// build single chat bubble cell with given text
UIView *returnView = [[UIView alloc] initWithFrame:CGRectZero];
returnView.backgroundColor = [UIColor clearColor];
//背影图片
UIImage *bubble = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:fromSelf?@"SenderAppNodeBkg_HL":@"ReceiverTextNodeBkg" ofType:@"png"]];
UIImageView *bubbleImageView = [[UIImageView alloc] initWithImage:[bubble stretchableImageWithLeftCapWidth:floorf(bubble.size.width/2) topCapHeight:floorf(bubble.size.height/2)]];
NSLog(@"%f,%f",size.width,size.height);
//添加文本信息
UILabel *bubbleText = [[UILabel alloc] initWithFrame:CGRectMake(fromSelf?15.0f:22.0f, 20.0f, size.width+10, size.height+10)];
bubbleText.backgroundColor = [UIColor clearColor];
bubbleText.font = font;
bubbleText.numberOfLines = 0;
bubbleText.lineBreakMode = NSLineBreakByWordWrapping;
bubbleText.text = text;
bubbleImageView.frame = CGRectMake(0.0f, 14.0f, bubbleText.frame.size.width+30.0f, bubbleText.frame.size.height+20.0f);
if(fromSelf)
returnView.frame = CGRectMake(320-position-(bubbleText.frame.size.width+30.0f), 0.0f, bubbleText.frame.size.width+30.0f, bubbleText.frame.size.height+30.0f);
else
returnView.frame = CGRectMake(position, 0.0f, bubbleText.frame.size.width+30.0f, bubbleText.frame.size.height+30.0f);
[returnView addSubview:bubbleImageView];
[returnView addSubview:bubbleText];
return returnView;
}
//泡泡语音
- (UIView *)yuyinView:(NSInteger)logntime from:(BOOL)fromSelf withIndexRow:(NSInteger)indexRow withPosition:(int)position{
//根据语音长度
int yuyinwidth = 66+fromSelf;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.tag = indexRow;
if(fromSelf)
button.frame =CGRectMake(320-position-yuyinwidth, 10, yuyinwidth, 54);
else
button.frame =CGRectMake(position, 10, yuyinwidth, 54);
//image偏移量
UIEdgeInsets imageInsert;
imageInsert.top = -10;
imageInsert.left = fromSelf?button.frame.size.width/3:-button.frame.size.width/3;
button.imageEdgeInsets = imageInsert;
[button setImage:[UIImage imageNamed:fromSelf?@"SenderVoiceNodePlaying":@"ReceiverVoiceNodePlaying"] forState:UIControlStateNormal];
UIImage *backgroundImage = [UIImage imageNamed:fromSelf?@"SenderVoiceNodeDownloading":@"ReceiverVoiceNodeDownloading"];
backgroundImage = [backgroundImage stretchableImageWithLeftCapWidth:20 topCapHeight:0];
[button setBackgroundImage:backgroundImage forState:UIControlStateNormal];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(fromSelf?-30:button.frame.size.width, 0, 30, button.frame.size.height)];
label.text = [NSString stringWithFormat:@"%d''",logntime];
label.textColor = [UIColor grayColor];
label.font = [UIFont systemFontOfSize:13];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
[button addSubview:label];
return button;
}
#pragma UITableView
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return _resultArray.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSDictionary *dict = [_resultArray objectAtIndex:indexPath.row];
UIFont *font = [UIFont systemFontOfSize:14];
CGSize size = [[dict objectForKey:@"content"] sizeWithFont:font constrainedToSize:CGSizeMake(180.0f, 20000.0f) lineBreakMode:NSLineBreakByWordWrapping];
return size.height+44;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}else{
for (UIView *cellView in cell.subviews){
[cellView removeFromSuperview];
}
}
NSDictionary *dict = [_resultArray objectAtIndex:indexPath.row];
//创建头像
UIImageView *photo ;
if ([[dict objectForKey:@"name"]isEqualToString:@"rhl"]) {
photo = [[UIImageView alloc]initWithFrame:CGRectMake(320-60, 10, 50, 50)];
[cell addSubview:photo];
photo.image = [UIImage imageNamed:@"photo1"];
if ([[dict objectForKey:@"content"] isEqualToString:@"0"]) {
[cell addSubview:[self yuyinView:1 from:YES withIndexRow:indexPath.row withPosition:65]];
}else{
[cell addSubview:[self bubbleView:[dict objectForKey:@"content"] from:YES withPosition:65]];
}
}else{
photo = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 50, 50)];
[cell addSubview:photo];
photo.image = [UIImage imageNamed:@"photo"];
if ([[dict objectForKey:@"content"] isEqualToString:@"0"]) {
[cell addSubview:[self yuyinView:1 from:NO withIndexRow:indexPath.row withPosition:65]];
}else{
[cell addSubview:[self bubbleView:[dict objectForKey:@"content"] from:NO withPosition:65]];
}
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
IOS的水滴文件效果的更多相关文章
- android 水纹上涨与水滴滴下效果
这两天项目比较紧,本来打算完成以后再写博客的,今天终于实现了一个炫的功能,怀着激动的心情,趁热打铁,把项目经验记录一下,效果图如下: 对功能的几点说明: 1.圆形边框旋转 2.水纹上涨 3.水滴滴下 ...
- 《IT蓝豹》高仿花田ios版标签移动效果
高仿花田ios版标签移动效果,长按每一个item拖动到自己想要位置后,后面位置移动补全效果 . 本项目适合研究gridview拖拽效果的朋友下载. 学习android动画特效. 本项目主要靠DragG ...
- iOS 工程中文件变成红色是什么情况
iOS 工程中文件变成红色是原有的文件路径改变了,系统找不到了.
- iOS的常见文件及程序的启动原理
一. iOS中常见文件 (一). Xcode6之前 创建项目,默认可以看见一个存放框架的文件夹 info文件以工程文件名开头,如:第一个项目-Info.plist 项目中默认有一个PCH文件 (二). ...
- iOS开发中文件的上传和下载功能的基本实现-备用
感谢大神分享 这篇文章主要介绍了iOS开发中文件的上传和下载功能的基本实现,并且下载方面讲到了大文件的多线程断点下载,需要的朋友可以参考下 文件的上传 说明:文件上传使用的时POST请求,通常把要上传 ...
- iOS Dev (22) 文件、路径
iOS Dev (22) 文件.路径 作者:CSDN 大锐哥 博客:http://blog.csdn.net/prevention 沙箱 Sandbox 的路径 和其他很多应用平台一样,iOS 也限定 ...
- IOS7上呈现IOS6的水滴刷新效果
IOS7上呈现IOS6的水滴刷新效果 到了IOS7 发现自带的刷新 不再是 IOS6自带的水滴效果了 你是否怀念那IOS6的效果呢? 哈哈,于是收集各方资料,整理编写一个属于自己的水滴刷新效果 ...
- IOS上传文件开发
IOS上传文件开发 在移动应用开发 文件形式上传是不可缺少的,近期把IOS这块文件上传文件代码简单的整理一下.假设大家有须要安卓这边的代码,本人也能够分享给大家! QQ群:74432915 ...
- iOS酷炫动画效果合集
iOS酷炫动画效果合集 源码地址 https://github.com/YouXianMing/Animations 效果绝对酷炫,包含了多种多样的动画类型,如POP.Easing.粒子效果等等,虽然 ...
随机推荐
- jsp项目上传到服务器
我们通过Myeclipse完成一个Java web项目时只能通过本地访问来查看,但是我们想把它上传到服务器上使用外网访问应该怎么做呢,首先肯定是要有一台服务器 个人调试项目试手的话我建议去买阿里云的云 ...
- [Selenium] 如何使 InternetExplorerDriver 每次启动的端口不会随机变化
InternetExplorerDriver 在不指定任何参数的情况下,启动监听端口会随机变化.如果需要保证其端口固定不变,可通过InternetExplorerDriverService 达到目的. ...
- 「LuoguP4752」牧 Divided Prime(判质数
Description 给定一个数字 A,这个 A 由 a1,a2,⋯,aN相乘得到. 给定一个数字 B,这个 B 由 b1,b2,⋯,bM相乘得到. 如果 A/B 是一个质数,请输出YES,否则输出 ...
- iOS copy/retain/assign
1 深复制:内容拷贝,源对象和副本对象指的是两个不同的对象,源对象引用计数器不变,副本对象引用计数器为1 2 浅复制:指针拷贝,源对象和副本对象指的都是同一个对象,对象引用计数器+1,相当于retai ...
- 如何让虚拟机的Ubuntu上网?
先声明 本文使用的虚拟机: VMware Workstation 14 Pro 本文使用的Ubuntu : ARM裸机1期加强版配套的Ubuntu16.04 特别注意:如果你使用的虚拟机和Ubuntu ...
- javascript ==等于与===恒等于
==判断是否等于,只判断数值 ===代表恒等于,不仅判断数值,而且判断类型 var a=5; var b="5"; (a b 只是数值上相等,但是类型并不相等) a==b //tr ...
- bzoj4556
后缀自动机+二分+倍增+线段树合并 后缀自动机真好用 后面一个串是固定的,那么我们要对前面的串进行一些操作.我们想既然是求lcp,那么我们得先翻转原串,这样前缀变成了后缀,然后二分一下,从d在自动机上 ...
- Java调用未被Static修饰的本类方法
public class Dy { public static void main(String[] args){ int a=6; int b=5; int result=0; Dy dy=new ...
- grep在指定类型的文件中查找字符 (转载)
转自:http://blog.csdn.net/qvbfndcwy/article/details/8127329 find -name '*.php'|xargs grep 'include'//在 ...
- E20180413-hm
skew adj. 斜的,歪的; [数学] 不对称的; [统计学] 歪斜,扭曲; vt. 歪曲; 曲解; 使歪斜; vi. 偏离,歪斜; 斜视; traversal n. 横越,横断物,(横 ...