123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- //
- // JXtopShowVIew.m
- // shiku_im
- //
- // Created by 123 on 2020/5/21.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXtopShowVIew.h"
- #import "JXLabelObject.h"
- @interface JXtopShowVIew()
- @property (weak, nonatomic) IBOutlet UIView *topRightView;
- /** 期数*/
- @property (weak, nonatomic) IBOutlet UILabel *qishuL;
- /**球的IMG*/
- @property (weak, nonatomic) UIView *qiuIMG;
- @property (nonatomic,weak) UIView *saiziView;
- @property (weak, nonatomic) IBOutlet UILabel *hezhiLL;
- @property (nonatomic,copy) NSString *indexSubType;
- @property (nonatomic,copy) NSString *indexCarSubType;
- @property (nonatomic,strong) UIImageView *shaiziIMG;
- @property (nonatomic,weak) UIScrollView *topScorllView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *hezhiConstraitH;
-
- /**底部View*/
- @property (weak, nonatomic) IBOutlet UIView *bottomView;
- @property (weak, nonatomic) IBOutlet UIButton *kaijjieguoBtn;
- @property (nonatomic,weak) UIButton *titBtn;
- @property (nonatomic,strong) NSMutableArray *dataArr2;
- @end
- @implementation JXtopShowVIew
- +(instancetype)xibJXtopShowVIew{
-
- return [[NSBundle mainBundle]loadNibNamed:@"JXtopShowVIew" owner:self options:nil].firstObject;
- }
- -(void)awakeFromNib{
- [super awakeFromNib];
- _dataArr2=[NSMutableArray array];
- _caizongBtn.layer.cornerRadius=8;
- _caizongBtn.layer.masksToBounds=YES;
- _tebieBtn.layer.cornerRadius=8;
- _tebieBtn.layer.masksToBounds=YES;
-
- _topRightView.layer.cornerRadius=8;
- _topRightView.layer.masksToBounds=YES;
-
- _kaijjieguoBtn.layer.cornerRadius=8;
- _kaijjieguoBtn.layer.masksToBounds=YES;
-
-
- //[g_notify addObserver:self selector:@selector(act_UserRoomAttention:) name:@"act_UserRoomAttention" object:nil];
-
- }
- -(void)setSelectItemModel:(JLSelectItemModel *)selectItemModel{
- _selectItemModel=selectItemModel;
-
- [_qiuIMG removeFromSuperview];
- UIView *qiuIMG = [[UIView alloc]init];
- qiuIMG.hidden=YES;
- [_topRightView addSubview:qiuIMG];
- self.qiuIMG=qiuIMG;
- [qiuIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(_topRightView.mas_centerY);
- make.left.mas_equalTo(_qishuL.mas_right).mas_offset(8);
- make.right.mas_equalTo(_hezhiLL.mas_left).mas_offset(-5);
- make.height.mas_equalTo(20);
- }];
-
- [_saiziView removeFromSuperview];
- UIView *saiziView = [[UIView alloc]init];
- saiziView.hidden=YES;
- [_topRightView addSubview:saiziView];
- self.saiziView=saiziView;
- [saiziView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(_topRightView.mas_centerY);
- make.left.mas_equalTo(_qishuL.mas_right).mas_offset(8);
- make.right.mas_equalTo(_hezhiLL.mas_left).mas_offset(-5);
- make.height.mas_equalTo(20);
- }];
-
-
-
- NSLog(@"选择 %@",selectItemModel.subType);
- if ([selectItemModel.subType intValue]==2) {
- _indexCarSubType=@"";
- _indexSubType=selectItemModel.content;
- NSArray *imagesArr=[_indexSubType componentsSeparatedByString:@":"];
-
- _qishuL.text = [imagesArr firstObject];
- _hezhiLL.text=[imagesArr lastObject];
-
- }else if ([selectItemModel.subType intValue]==3) { //赛车
- _indexSubType=@"";
- _indexCarSubType=selectItemModel.content;
- NSArray *imagesArr=[_indexCarSubType componentsSeparatedByString:@":"];
-
- _qishuL.text = [imagesArr firstObject];
- _hezhiLL.text=[imagesArr lastObject];
-
-
- }else if ([selectItemModel.subType intValue]==4) { //标黄色
- _indexCarSubType=@"";
- _indexSubType=@"";
- NSArray *titleContent= [selectItemModel.content componentsSeparatedByString:@":"];
-
- NSMutableAttributedString *hintString1=[[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@%@",[titleContent firstObject],titleContent[1] ,[titleContent lastObject]]];
- NSRange range2=[[hintString1 string]rangeOfString:titleContent[1]];
- [hintString1 addAttribute:NSForegroundColorAttributeName value:[UIColor orangeColor] range:range2];
- _qishuL.attributedText = hintString1;
-
- _hezhiLL.text=[titleContent lastObject];
-
- self.hezhiConstraitH.constant=140+40;
- _saiziView.hidden=YES;
- _qiuIMG.hidden=YES;
- }else{
- _qishuL.text = selectItemModel.content;
-
-
- _saiziView.hidden=YES;
- _qiuIMG.hidden=YES;
-
- self.hezhiConstraitH.constant=140+40;
- }
-
- //CGFloat qishuSize=[self titleBtnWight:_qishuL.text and:_qishuL].width;
-
-
-
- if (_indexCarSubType.length>0) {
-
- _saiziView.hidden=NO;
- _qiuIMG.hidden=YES;
-
- NSArray *imagesArr=[_indexCarSubType componentsSeparatedByString:@":"];
-
- NSArray *numberS=[imagesArr[1] componentsSeparatedByString:@","];
-
- self.hezhiConstraitH.constant=45+numberS.count*21+40;
-
- for (int i=0; i<numberS.count; i++) {
-
- _shaiziIMG = [[UIImageView alloc] init];
-
- if ([numberS[i] intValue]==10) {
-
- _shaiziIMG.image=[UIImage imageNamed:[NSString stringWithFormat:@"%@",numberS[i]]];
- }else{
-
- _shaiziIMG.image=[UIImage imageNamed:[NSString stringWithFormat:@"0%@",numberS[i]]];
- }
-
- [_saiziView addSubview:_shaiziIMG];
- _shaiziIMG.frame=CGRectMake(0 +i*(20+1), 0, 20, 20);
- }
-
- _hezhiLL.text=[NSString stringWithFormat:@"%@",[imagesArr lastObject]];
-
- }
-
- if (_indexSubType.length>0) {
-
- _saiziView.hidden=YES;
- _qiuIMG.hidden=NO;
-
- NSArray *imagesArr=[_indexSubType componentsSeparatedByString:@":"];
-
- NSArray *numberS=[imagesArr[1] componentsSeparatedByString:@","];
-
- self.hezhiConstraitH.constant=45+numberS.count*21+40;
-
-
- for (int i=0; i<numberS.count; i++) {
-
- _shaiziIMG = [[UIImageView alloc] init];
-
- _shaiziIMG.image=[UIImage imageNamed:[NSString stringWithFormat:@"shaizi%@",numberS[i]]];
-
- [_qiuIMG addSubview:_shaiziIMG];
- _shaiziIMG.frame=CGRectMake(0 +i*(20+1), 0, 20, 20);
- }
-
- _hezhiLL.text=[NSString stringWithFormat:@"%@",[imagesArr lastObject]];
-
- }
-
-
-
- }
- -(CGSize)titleBtnWight:(NSString *)titBtnW and:(UILabel *)titBtn {
- CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(MAXFLOAT, 24) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn.font} context:nil].size;
-
- return titleSize;
- }
- /*
- - (void)act_UserRoomAttention:(NSNotification *)note{
-
- NSDictionary *dict=note.userInfo;
- NSArray *tempArr=dict[@"user"];
-
- _dataArr2=[tempArr mutableCopy];
-
- CGFloat titBtnX =10;
- for(int i =0; i <tempArr.count; i++){
-
- memberData *model=tempArr[i];
- UIButton *titBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- titBtn.titleLabel.font= [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
- [titBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal];
- [titBtn setTitle:model.userNickName forState:UIControlStateNormal];
- titBtn.backgroundColor=[UIColor whiteColor];
- titBtn.layer.cornerRadius=10;
- titBtn.layer.masksToBounds=YES;
- titBtn.tag=i;
- CGSize titleSize=[self titleBtnWightBtb:model.userNickName and:titBtn];
- CGFloat titBtnW = titleSize.width+5;
- titBtn.frame=CGRectMake(titBtnX, 6, titBtnW, 24);
-
- titBtnX += titBtnW + 10;
- [ self.topScorllView addSubview:titBtn];
- self.titBtn=titBtn;
- [titBtn addTarget:self action:@selector(titleUserBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-
- }
-
- self.topScorllView.contentSize=CGSizeMake(_dataArr2.count *(64)+100, 0);
- }
- */
- - (void)titleUserBtnClick:(UIButton *)btn{
-
- if (_jxGuanXinBlockBtn) {
- _jxGuanXinBlockBtn(btn);
- }
- }
- //json格式字符串转字典:
- - (NSArray *)dictionaryWithJsonString:(NSString *)jsonString {
-
- if (jsonString == nil) {
-
- return nil;
-
- }
-
- NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
-
- NSError *err;
-
- NSArray *dic = [NSJSONSerialization JSONObjectWithData:jsonData
-
- options:NSJSONReadingMutableContainers
-
- error:&err];
-
- if(err) {
-
- NSLog(@"json解析失败:%@",err);
-
- return nil;
-
- }
-
- return dic;
-
- }
- -(CGSize)titleBtnWightBtb:(NSString *)titBtnW and:(UIButton *)titBtn {
- CGSize titleSize = [titBtnW boundingRectWithSize:CGSizeMake(MAXFLOAT, 24) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:titBtn.titleLabel.font} context:nil].size;
-
- return titleSize;
- }
- @end
|