IOS类似于微信和qq的泡泡语音

来源:互联网 发布:淘宝怎样领取淘金币 编辑:程序博客网 时间:2024/04/30 21:21

// 未简化 不可复用 仅供参考

//泡泡语音
- (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;

}

3 0
原创粉丝点击