123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- //
- // JXSiDaiCell.m
- // shiku_im
- //
- // Created by 123 on 2020/6/4.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXSiDaiCell.h"
- #import "UIButton+WebCache.h"
- #import "MJPhotoBrowser.h"
- #import "MJPhoto.h"
- @interface JXSiDaiCell()
- @property (weak, nonatomic) IBOutlet UIImageView *iconIMG;
- @property (weak, nonatomic) IBOutlet UILabel *titleName;
- @property (weak, nonatomic) IBOutlet UILabel *techerName;
- @property (weak, nonatomic) IBOutlet UILabel *techerLevel;
- @property (nonatomic,weak) IBOutlet UILabel *titleL;
- @property (nonatomic,weak) IBOutlet UILabel *awreResultL;
- @property (nonatomic,weak) IBOutlet UIButton *yuyueBtn;
- /**战果展示*/
- @property (weak, nonatomic) IBOutlet UIView *awarView;
- @property (weak, nonatomic) IBOutlet UILabel *kechenPriceL;
- /**左边背景*/
- @property (weak, nonatomic) IBOutlet UIView *leftView;
- //右边背景
- @property (weak, nonatomic) IBOutlet UIView *kecView;
- @property (weak, nonatomic) IBOutlet UIView *zhanguoView;
- @end
- @implementation JXSiDaiCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code\
-
- _leftView.layer.cornerRadius=5;
- _leftView.layer.masksToBounds=YES;
- _kecView.layer.cornerRadius=5;
- _kecView.layer.masksToBounds=YES;
- _yuyueBtn.layer.cornerRadius=3;
- _yuyueBtn.layer.masksToBounds=YES;
- [_yuyueBtn addTarget:self action:@selector(yuyueBtnClick:) forControlEvents:UIControlEventTouchUpInside];
-
-
-
- }
- - (void)yuyueBtnClick:(UIButton *)sender{
- if (_yuyueblock) {
- _yuyueblock(sender);
- }
-
- }
-
- + (instancetype)cellWithTableView:(UITableView *)tableView
- {
- static NSString *ID = @"JXSiDaiCell";
- JXSiDaiCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
- if (!cell) {
- cell = [[NSBundle mainBundle] loadNibNamed:@"JXSiDaiCell" owner:nil options:nil].firstObject;
- cell.selectionStyle=UITableViewCellSelectionStyleNone;
- }
- cell.backgroundColor=[UIColor clearColor];
-
-
- return cell;
- }
- - (NSAttributedString *)stringHtml:(NSString *)htmlStr{
-
-
- NSDictionary *optoins=@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType,
- NSFontAttributeName:[UIFont systemFontOfSize:14]};
- NSData *data=[htmlStr dataUsingEncoding:NSUnicodeStringEncoding];
- NSAttributedString *attributeString=[[NSAttributedString alloc] initWithData:data
- options:optoins documentAttributes:nil error:nil];
-
- return attributeString;
- }
- -(void)setDictData:(NSDictionary *)dictData{
- _dictData=dictData;
- self.titleName.text=[NSString stringWithFormat:@"%@",dictData[@"name"]];
- [self.iconIMG sd_setImageWithURL:[NSURL URLWithString:dictData[@"photoUrl"]] placeholderImage:[UIImage imageNamed:@""]];
-
- self.techerName.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"intro"]]];
- self.techerLevel.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"message"]]];
- self.titleL.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"income"]]];
-
- CGFloat marginW=15;
-
- if (JX_SCREEN_WIDTH<414) {
- marginW=5;
- }
- CGFloat imageW=60;
-
-
- NSArray *imageS=dictData[@"achievement"];
- for (int i=0; i<imageS.count;i++) {
-
- UIButton *imageV=[[UIButton alloc]init];
- [imageV sd_setImageWithURL:[NSURL URLWithString:imageS[i]] forState:UIControlStateNormal];
-
- imageV.tag=i;
- [_zhanguoView addSubview:imageV];
- imageV.frame=CGRectMake(1+i%3*(imageW +marginW), 0+i/3*(imageW +12), imageW, imageW);
- [imageV addTarget:self action:@selector(imageBtClick:) forControlEvents:UIControlEventTouchUpInside];
- }
-
- self.kechenPriceL.attributedText=[self stringHtml:[NSString stringWithFormat:@"%@",dictData[@"price"]]];
-
- }
- - (void)imageBtClick:(UIButton *)sender{
-
- NSArray *imageS=_dictData[@"achievement"];
- MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
- // 2.设置图片浏览器显示的所有图片
- NSMutableArray *photos = [NSMutableArray array];
- NSInteger count = imageS.count;
- for (NSInteger i = 0; i<count; i++) {
- MJPhoto *photo = [[MJPhoto alloc] init];
- photo.url = [NSURL URLWithString:imageS[i]];
- UIButton *btnImag=_zhanguoView.subviews[i];
- photo.srcImageView =btnImag.imageView;
- [photos addObject:photo];
- }
- browser.photos = photos;
- // 3.设置默认显示的图片索引
- browser.currentPhotoIndex = sender.tag;
-
- // 3.显示浏览器
- [browser show];
-
- }
- -(void)setFrame:(CGRect)frame{
- frame.origin.y+=20;
- frame.size.height-=20;
- [super setFrame:frame];
- }
- @end
|