QMChatTileView.m 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // QMChatTileView.m
  3. // IMSDK-OC
  4. //
  5. // Created by HCF on 16/8/10.
  6. // Copyright © 2016年 HCF. All rights reserved.
  7. //
  8. #import "QMChatTileView.h"
  9. @implementation QMChatTileView
  10. - (instancetype)initWithFrame:(CGRect)frame {
  11. self = [super initWithFrame:frame];
  12. if (self) {
  13. [self createUI];
  14. }
  15. return self;
  16. }
  17. - (void)createUI {
  18. self.nameLabel = [[UILabel alloc] init];
  19. self.nameLabel.textAlignment = NSTextAlignmentCenter;
  20. self.nameLabel.textColor = [UIColor blackColor];
  21. self.nameLabel.font = [UIFont systemFontOfSize:18];
  22. [self addSubview:self.nameLabel];
  23. self.stateInfoLabel = [[UILabel alloc] init];
  24. self.stateInfoLabel.textAlignment = NSTextAlignmentCenter;
  25. self.stateInfoLabel.textColor = [UIColor grayColor];
  26. self.stateInfoLabel.font = [UIFont systemFontOfSize:14];
  27. [self addSubview:self.stateInfoLabel];
  28. self.nameLabel.translatesAutoresizingMaskIntoConstraints = NO;
  29. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]];
  30. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:0.0]];
  31. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]];
  32. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.nameLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:26]];
  33. self.stateInfoLabel.translatesAutoresizingMaskIntoConstraints = NO;
  34. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0.0]];
  35. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.nameLabel attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0.0]];
  36. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeRight multiplier:1.0 constant:0.0]];
  37. [self addConstraint:[NSLayoutConstraint constraintWithItem:self.stateInfoLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeHeight multiplier:1.0 constant:16]];
  38. }
  39. @end