04环信聊天界面 - 接收方cell的布局

1.拖一个UITabelViewCell到聊天界面的tableView里。cell里需要添加3个控件,1个UIImageView作为头像,一个UILabel(显示聊天文字),另一个imageView(作为label的背景)。

控件关系:背景的imageView其实就是聊天气泡,文字在气泡内,文字和气泡有边距。


头像尺寸35x35, UILabel设置Lines属性为0就可以换行,并且要设置最大宽度


约束:

chatListCellHead头像控件的约束如图:


chat_receiver_bg背景图片的约束:


Message Label的约束:


注意,label和背景imageView之间 左右上下 为0


2.新建ChatCell 继承自 UITableViewCell,让刚那个cell 指向这个类

然后连线

//
//  ChatCell.h


#import <UIKit/UIKit.h>

@interface ChatCell : UITableViewCell

@property (weak, nonatomic) IBOutlet UILabel *messageLabel;
@end
3.在聊天控制器 ChatViewController  里< UITableViewDataSource , UITableViewDelegate >

#pragma mark -UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ID = @"recivierCell";
    ChatCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    cell.messageLabel.text = @"阿里的杰拉德加咖喱的空间旮旯的空间按了个凯迪拉克加咖喱块的架构拉开到加咖喱块大公鸡";
    return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}
预览效果:




最后:发送方的cell,也是同理设置。这就不具体说了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值