1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- //
- // QMChatTileView.m
- // IMSDK-OC
- //
- // Created by HCF on 16/8/10.
- // Copyright © 2016年 HCF. All rights reserved.
- //
- #import "QMChatTileView.h"
- @implementation QMChatTileView
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- [self createUI];
- }
- return self;
- }
- - (void)createUI {
- self.nameLabel = [[UILabel alloc] init];
- self.nameLabel.textAlignment = NSTextAlignmentCenter;
- self.nameLabel.textColor = [UIColor blackColor];
- self.nameLabel.font = [UIFont systemFontOfSize:18];
- [self addSubview:self.nameLabel];
-
- self.stateInfoLabel = [[UILabel alloc] init];
- self.stateInfoLabel.textAlignment = NSTextAlignmentCenter;
- self.stateInfoLabel.textColor = [UIColor grayColor];
- self.stateInfoLabel.font = [UIFont systemFontOfSize:14];
- [self addSubview:self.stateInfoLabel];
-
- self.nameLabel.translatesAutoresizingMaskIntoConstraints = NO;
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:26]];
-
- self.stateInfoLabel.translatesAutoresizingMaskIntoConstraints = NO;
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.nameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]];
- [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:16]];
- }
- @end
|