VowBar.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // VowBar.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/1/15.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "VowBar.h"
  9. @implementation VowBar
  10. -(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self)
  14. {
  15. self.backgroundColor = [UIColor whiteColor];
  16. CGFloat width = frame.size.width;
  17. CGFloat hight = width/3.0;
  18. CGFloat margin = (width - 10)/7.0;
  19. CGFloat imageW = margin - 4;
  20. CGFloat labelH = (hight - margin)/2;
  21. UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 80, labelH)];
  22. label1.text = title;
  23. label1.textColor = kTitleColor;
  24. label1.font = [UIFont scaleSize:16];
  25. [self addSubview:label1];
  26. _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(width - 140, 0, 120, labelH)];
  27. _countLabel.font = [UIFont scaleSize:15];
  28. _countLabel.textColor = contentTextColor;
  29. [self addSubview:_countLabel];
  30. UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(30, labelH + margin, 80, labelH)];
  31. label3.text = @"考前许愿";
  32. label3.font = [UIFont scaleSize:14];
  33. label3.textColor = subTitleColor;
  34. [self addSubview:label3];
  35. UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(width - 205, labelH + margin, 185, labelH)];
  36. label4.text = @"在这里许过愿的人都过了哦!";
  37. label4.font = [UIFont scaleSize:14];
  38. label4.textColor = contentTextColor;
  39. [self addSubview:label4];
  40. UIImageView *heart = [[UIImageView alloc] initWithFrame:CGRectMake(10, labelH + margin + 10, 15, 15)];
  41. heart.image = [UIImage imageNamed:@"heart"];
  42. [self addSubview:heart];
  43. NSMutableArray *images = [NSMutableArray array];
  44. for (int i = 0; i < 16; i ++)
  45. {
  46. [images addObject:[NSString stringWithFormat:@"portrait%d",i + 1]];
  47. }
  48. NSMutableArray *image = [NSMutableArray array];
  49. for (int i = 0; i < 7; i ++)
  50. {
  51. int index = arc4random()%(images.count-1);
  52. [image addObject:images[index]];
  53. [images removeObjectAtIndex:index];
  54. }
  55. for (int i = 0; i < 7; i ++)
  56. {
  57. UIImageView *headImg = [[UIImageView alloc] initWithFrame:CGRectMake(10 + i*margin, labelH + 4, imageW, imageW)];
  58. headImg.image = [UIImage imageNamed:image[i]];
  59. [headImg setRound];
  60. [self addSubview:headImg];
  61. }
  62. UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, labelH)];
  63. [btn setBoardWid:.5 Color:KlineColor];
  64. [self addSubview:btn];
  65. _topicBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, labelH + margin + 4)];
  66. [_topicBtn setBoardWid:.5 Color:KlineColor];
  67. [self addSubview:_topicBtn];
  68. _vomBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, labelH + margin + 2, width, frame.size.height - labelH - margin - 4)];
  69. // [_vomBtn setBoardWid:.5 Color:KlineColor];
  70. [self addSubview:_vomBtn];
  71. }
  72. return self;
  73. }
  74. @end