| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /************************************************************
- * * Hyphenate CONFIDENTIAL
- * __________________
- * Copyright (C) 2016 Hyphenate Inc. All rights reserved.
- *
- * NOTICE: All information contained herein is, and remains
- * the property of Hyphenate Inc.
- * Dissemination of this information or reproduction of this material
- * is strictly forbidden unless prior written permission is obtained
- * from Hyphenate Inc.
- */
- #import "EaseMessageTimeCell.h"
- CGFloat const EaseMessageTimeCellPadding = 5;
- @interface EaseMessageTimeCell()
- @property (strong, nonatomic) UILabel *titleLabel;
- @end
- @implementation EaseMessageTimeCell
- + (void)initialize
- {
- // UIAppearance Proxy Defaults
- EaseMessageTimeCell *cell = [self appearance];
- cell.titleLabelColor = [UIColor grayColor];
- cell.titleLabelFont = [UIFont systemFontOfSize:12];
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style
- reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- self.backgroundColor = [UIColor clearColor];
- [self _setupSubview];
- }
-
- return self;
- }
- #pragma mark - setup subviews
- - (void)_setupSubview
- {
- _titleLabel = [[UILabel alloc] init];
- _titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
- _titleLabel.textAlignment = NSTextAlignmentCenter;
- _titleLabel.backgroundColor = [UIColor clearColor];
- _titleLabel.textColor = _titleLabelColor;
- _titleLabel.font = _titleLabelFont;
- [self.contentView addSubview:_titleLabel];
-
- [self _setupTitleLabelConstraints];
- }
- #pragma mark - Setup Constraints
- - (void)_setupTitleLabelConstraints
- {
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:EaseMessageTimeCellPadding]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:-EaseMessageTimeCellPadding]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:-EaseMessageTimeCellPadding]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.titleLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:EaseMessageTimeCellPadding]];
- }
- #pragma mark - setter
- - (void)setTitle:(NSString *)title
- {
- _title = title;
- _titleLabel.text = _title;
- }
- - (void)setTitleLabelFont:(UIFont *)titleLabelFont
- {
- _titleLabelFont = titleLabelFont;
- _titleLabel.font = _titleLabelFont;
- }
- - (void)setTitleLabelColor:(UIColor *)titleLabelColor
- {
- _titleLabelColor = titleLabelColor;
- _titleLabel.textColor = _titleLabelColor;
- }
- #pragma mark - public
- + (NSString *)cellIdentifier
- {
- return @"MessageTimeCell";
- }
- @end
|