ButtonView.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // ButtonView.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/8/15.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ButtonView.h"
  9. @implementation ButtonView
  10. -(id)initWithFrame:(CGRect)frame Image:(NSString *)aImg Title:(NSString *)aTitle Detail:(NSString *)aDetail type:(NSInteger)aType
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor = backGroundColor;
  15. [self setBoardWid:1 Color:backGroundColor];
  16. CGFloat wid = frame.size.width;
  17. CGFloat x,y,w,h;
  18. w = h = 25;
  19. x = (wid *2.0/7.0 - w)/2.0;
  20. y = 10;
  21. _imgView = [[UIImageView alloc] setxywh];
  22. _imgView.image = [UIImage imageNamed:aImg];
  23. [self addSubview:_imgView];
  24. if (aType == 1) {
  25. x = wid *2.0/7.0;
  26. w = wid - x - 1;
  27. h = 20;
  28. _titleLabel = [[UILabel alloc] setxywh];
  29. [_titleLabel setText:aTitle Font:16 TextColor:kTitleColor];
  30. [self addSubview:_titleLabel];
  31. y += h + 5;
  32. h = 20;
  33. _detailLabel = [[UILabel alloc] setxywh];
  34. [_detailLabel setText:aDetail Font:14 TextColor:contentTextColor];
  35. _detailLabel.adjustsFontSizeToFitWidth = YES;
  36. _detailLabel.minimumScaleFactor = 0.9;
  37. [self addSubview:_detailLabel];
  38. }
  39. if (aType == 2) {
  40. x = wid *2.0/7.0;
  41. w = wid - x - 1;
  42. h = 25;
  43. _titleLabel = [[UILabel alloc] setxywh];
  44. [_titleLabel setText:aTitle Font:16 TextColor:kTitleColor];
  45. [self addSubview:_titleLabel];
  46. }
  47. }
  48. return self;
  49. }
  50. @end