Nessuna descrizione

FKBookTitleBtn.m 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //
  2. // FKBookTitleBtn.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/4/28.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKBookTitleBtn.h"
  9. @interface FKBookTitleBtn ()
  10. @property (nonatomic, strong) UIImageView *arrowImgView;
  11. @end
  12. @implementation FKBookTitleBtn
  13. - (instancetype)initWithFrame:(CGRect)frame{
  14. if (self = [super initWithFrame:frame]) {
  15. [self addAllSubviews];
  16. }
  17. return self;
  18. }
  19. - (void)addAllSubviews{
  20. [self addSubview:self.arrowImgView];
  21. [self addSubview:self.titleLabel];
  22. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  23. make.centerX.equalTo(self).offset(- 10);
  24. make.centerY.equalTo(self);
  25. }];
  26. [self.arrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.centerY.equalTo(self.titleLabel);
  28. make.left.equalTo(self.titleLabel.mas_right).offset(5);
  29. }];
  30. }
  31. - (void)setSelected:(BOOL)selected{
  32. [super setSelected:selected];
  33. if (selected){
  34. self.arrowImgView.transform = CGAffineTransformMakeRotation(M_PI);
  35. }else{
  36. self.arrowImgView.transform = CGAffineTransformIdentity;
  37. }
  38. }
  39. - (UIImageView *)arrowImgView{
  40. if (_arrowImgView == nil) {
  41. _arrowImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"book_red_arrow"]];
  42. }
  43. return _arrowImgView;
  44. }
  45. - (UILabel *)titleLabel{
  46. if (_titleLabel == nil) {
  47. _titleLabel = [[UILabel alloc]init];
  48. _titleLabel.textColor = UIColorFromRGB(0x4a4a4a);
  49. _titleLabel.font = [UIFont systemFontOfSize:18];
  50. _titleLabel.text = @"我的订阅";
  51. }
  52. return _titleLabel;
  53. }
  54. @end