新浪微博客户端(48)-添加删除按钮到表情键盘
2016-12-01 21:55
281 查看
DJEmotionPageView.m
最终效果:
- (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { UIButton *deleteBtn = [[UIButton alloc] init]; [deleteBtn setImage:[UIImage imageNamed:@"compose_emotion_delete"] forState:UIControlStateNormal]; [deleteBtn setImage:[UIImage imageNamed:@"compose_emotion_delete_highlighted"] forState:UIControlStateHighlighted]; [self addSubview:deleteBtn]; self.deleteBtn = deleteBtn; } return self; }
- (void)layoutSubviews { [super layoutSubviews]; CGFloat emotionW = (self.width - 2 * DJEmotionPageViewPadding) / DJEmotionPageViewMaxCols; CGFloat emotionH = (self.height - DJEmotionPageViewPadding) / DJEmotionPageViewMaxRows; NSUInteger emotionsCount = self.emotions.count; for (int i = 0; i < emotionsCount; i++) { UIView *emotionView = self.subviews[i+1]; // 遍历应该从第1个按钮,不应该从第0个,因为第0个View是删除按钮 emotionView.x = (i % DJEmotionPageViewMaxCols) * emotionW + DJEmotionPageViewPadding; emotionView.y = (i / DJEmotionPageViewMaxCols) * emotionH + DJEmotionPageViewPadding; emotionView.width = emotionW; emotionView.height = emotionH; } // 删除按钮 CGFloat deleteBtnW = emotionW; CGFloat deleteBtnH = emotionH; CGFloat deleteBtnX = self.width - DJEmotionPageViewPadding - deleteBtnW; CGFloat deleteBtnY = self.height - deleteBtnH; self.deleteBtn.frame = CGRectMake(deleteBtnX, deleteBtnY, deleteBtnW, deleteBtnH); }
最终效果:
相关文章推荐
- 为删除按钮添加客户端确认事件
- 新浪微博客户端(44)-分页表情键盘
- 新浪微博客户端(49)-删除输入的Emotion表情
- 1怎样让输入的text文本填写的部分只添加数字、2怎样将输入的数字一次性全部删除 3怎样选择密码 让它不显示 4 怎样实现在没有return的情况下点击button的情况下就能够使键盘页面下落5 怎样实现点击指定的button来对使指定的text进行键盘弹出 6怎样改变button按钮的状态
- 新浪微博客户端(42)-完善表情键盘的工具条
- 新浪微博客户端(8)-添加按钮到TabBar
- 仿新浪微博IOS客户端(v5.2.8)——自定义UITabBar替换系统默认的(添加“+”号按钮),
- 新浪微博客户端(46)-点击表情按钮弹出表情
- Scott Mitchell 的ASP.NET 2.0数据教程之四十二::为删除数据添加客户端确认
- Google终于屈服,Gmail添加删除按钮
- 给DataGrid的删除按钮添加"删除确认"对话框
- 给GridView删除按钮添加提示框
- Scott Mitchell 的ASP.NET 2.0数据教程之四十二::为删除数据添加客户端确认
- Scott Mitchell 的ASP.NET 2.0数据教程之二十二:为删除数据添加客户端确认
- 给VS2005的GridView控件自带的删除按钮添加确认
- 给DataGrid的删除按钮添加"删除确认"对话框
- ListBox在客户端添加删除操作
- Scott Mitchell 的ASP.NET 2.0数据教程之四十二::为删除数据添加客户端确认
- 为DataGrid/DataList删除按钮添加删除确认
- 给DataGrid的删除按钮添加"删除确认"对话框