123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- //
- // VowBar.m
- // jiaPei
- //
- // Created by apple on 16/1/15.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "VowBar.h"
- @implementation VowBar
- -(instancetype)initWithFrame:(CGRect)frame title:(NSString *)title
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- self.backgroundColor = [UIColor whiteColor];
-
- CGFloat width = frame.size.width;
- CGFloat hight = width/3.0;
- CGFloat margin = (width - 10)/7.0;
- CGFloat imageW = margin - 4;
- CGFloat labelH = (hight - margin)/2;
-
- UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, 80, labelH)];
- label1.text = title;
- label1.textColor = kTitleColor;
- label1.font = [UIFont scaleSize:16];
- [self addSubview:label1];
-
- _countLabel = [[UILabel alloc] initWithFrame:CGRectMake(width - 140, 0, 120, labelH)];
- _countLabel.font = [UIFont scaleSize:15];
- _countLabel.textColor = contentTextColor;
- [self addSubview:_countLabel];
-
- UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(30, labelH + margin, 80, labelH)];
- label3.text = @"考前许愿";
- label3.font = [UIFont scaleSize:14];
- label3.textColor = subTitleColor;
- [self addSubview:label3];
-
- UILabel *label4 = [[UILabel alloc] initWithFrame:CGRectMake(width - 205, labelH + margin, 185, labelH)];
- label4.text = @"在这里许过愿的人都过了哦!";
- label4.font = [UIFont scaleSize:14];
- label4.textColor = contentTextColor;
- [self addSubview:label4];
-
- UIImageView *heart = [[UIImageView alloc] initWithFrame:CGRectMake(10, labelH + margin + 10, 15, 15)];
- heart.image = [UIImage imageNamed:@"heart"];
- [self addSubview:heart];
-
- NSMutableArray *images = [NSMutableArray array];
- for (int i = 0; i < 16; i ++)
- {
- [images addObject:[NSString stringWithFormat:@"portrait%d",i + 1]];
- }
- NSMutableArray *image = [NSMutableArray array];
- for (int i = 0; i < 7; i ++)
- {
- int index = arc4random()%(images.count-1);
- [image addObject:images[index]];
- [images removeObjectAtIndex:index];
- }
-
- for (int i = 0; i < 7; i ++)
- {
- UIImageView *headImg = [[UIImageView alloc] initWithFrame:CGRectMake(10 + i*margin, labelH + 4, imageW, imageW)];
- headImg.image = [UIImage imageNamed:image[i]];
- [headImg setRound];
- [self addSubview:headImg];
- }
-
- UIButton* btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, labelH)];
- [btn setBoardWid:.5 Color:KlineColor];
- [self addSubview:btn];
-
- _topicBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, labelH + margin + 4)];
- [_topicBtn setBoardWid:.5 Color:KlineColor];
- [self addSubview:_topicBtn];
-
- _vomBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, labelH + margin + 2, width, frame.size.height - labelH - margin - 4)];
- // [_vomBtn setBoardWid:.5 Color:KlineColor];
- [self addSubview:_vomBtn];
- }
- return self;
- }
- @end
|