引导UI修改
This commit is contained in:
@@ -4,8 +4,11 @@
|
||||
//
|
||||
|
||||
#import "KBGuideUserCell.h"
|
||||
#import "KBUserSessionManager.h"
|
||||
#import "KBUser.h"
|
||||
|
||||
@interface KBGuideUserCell ()
|
||||
@property (nonatomic, strong) UIImageView *avatarImageView; // 右侧用户头像
|
||||
@property (nonatomic, strong) UIView *bubbleView; // 右侧紫色气泡
|
||||
@property (nonatomic, strong) UILabel *contentLabel;
|
||||
@end
|
||||
@@ -15,9 +18,16 @@
|
||||
- (void)setupUI {
|
||||
self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
|
||||
|
||||
[self.contentView addSubview:self.avatarImageView];
|
||||
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
make.top.equalTo(self.contentView).offset(10);
|
||||
make.width.height.mas_equalTo(36);
|
||||
}];
|
||||
|
||||
[self.contentView addSubview:self.bubbleView];
|
||||
[self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.contentView).offset(-16);
|
||||
make.right.equalTo(self.avatarImageView.mas_left).offset(-8);
|
||||
make.top.equalTo(self.contentView).offset(8);
|
||||
make.left.greaterThanOrEqualTo(self.contentView).offset(80);
|
||||
make.bottom.equalTo(self.contentView).offset(-8);
|
||||
@@ -31,14 +41,50 @@
|
||||
|
||||
- (void)configText:(NSString *)text {
|
||||
self.contentLabel.text = text;
|
||||
self.avatarImageView.image = [self kb_resolvedAvatarImage];
|
||||
}
|
||||
|
||||
#pragma mark - Helpers
|
||||
|
||||
- (UIImage *)kb_resolvedAvatarImage {
|
||||
UIImage *placeholder = [UIImage imageNamed:@"placeholder_icon"];
|
||||
|
||||
KBUserSessionManager *session = [KBUserSessionManager shared];
|
||||
if (![session isLoggedIn]) {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
KBUser *user = session.currentUser;
|
||||
if (!user) {
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
switch (user.gender) {
|
||||
case UserSexMan:
|
||||
return [UIImage imageNamed:@"message_man_icon"] ?: placeholder;
|
||||
case UserSexWeman:
|
||||
return [UIImage imageNamed:@"message_nv_icon"] ?: placeholder;
|
||||
default:
|
||||
return placeholder;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Lazy
|
||||
|
||||
- (UIImageView *)avatarImageView {
|
||||
if (!_avatarImageView) {
|
||||
_avatarImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"placeholder_icon"]];
|
||||
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_avatarImageView.layer.cornerRadius = 18;
|
||||
_avatarImageView.layer.masksToBounds = YES;
|
||||
}
|
||||
return _avatarImageView;
|
||||
}
|
||||
|
||||
- (UIView *)bubbleView {
|
||||
if (!_bubbleView) {
|
||||
_bubbleView = [UIView new];
|
||||
_bubbleView.backgroundColor = [UIColor colorWithRed:0.42 green:0.45 blue:0.98 alpha:1.0];
|
||||
_bubbleView.backgroundColor = [UIColor colorWithHex:KBColorValue];
|
||||
_bubbleView.layer.cornerRadius = 12;
|
||||
_bubbleView.layer.masksToBounds = YES;
|
||||
}
|
||||
@@ -57,4 +103,3 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user