ifish/Ifish/controllers/IfishTabControllers/探索/lookafterServer/KanHuFuWuXInRuKou/ShopDetailCodeFirstCell.m

171 lines
5.8 KiB
Objective-C

//
// ShopDetailCodeFirstCell.m
// Ifish
//
// Created by imac on 17/1/19.
// Copyright © 2017年 lianlian. All rights reserved.
//
#import "ShopDetailCodeFirstCell.h"
#import "UIImageView+WebCache.h"
@implementation ShopDetailCodeFirstCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
[self setUI];
[self setItemsCorner];
}
return self;
}
-(void)setUI{
CGFloat CellH = kScreenSize.width*0.38;
CGFloat ImgTopMargin = CellH * 0.14;
CGFloat ImgW = CellH *0.40;
self.shopImg = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenSize.width/2-ImgW/2, ImgTopMargin,ImgW, ImgW)];
[self addSubview:self.shopImg];
CGFloat labelH= 13;
CGFloat labelW= 48;
self.nYear = [[UILabel alloc] initWithFrame:CGRectMake(self.shopImg.frame.origin.x - labelW -1, self.shopImg.center.y -labelH/2,labelW, labelH)];
self.nYear.font = [UIFont systemFontOfSize:10];
self.nYear.textColor = [UIColor whiteColor];
self.nYear.backgroundColor = RGB(0, 180, 239);
self.nYear.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.nYear];
CGFloat nYearOrignx = CGRectGetMaxX(self.shopImg.frame);
CGFloat nYearOrignY =CellH *0.18;
self.province = [[UILabel alloc] initWithFrame:CGRectMake(nYearOrignx - 2, nYearOrignY,52,labelH)];
self.province.textAlignment = NSTextAlignmentCenter;
self.province.font = [UIFont systemFontOfSize:10];
self.province.textColor = [UIColor whiteColor];
self.province.backgroundColor = RGB(255,115,92);
[self addSubview:self.province];
// 255 169 86
CGFloat vRenZhengOrignY =CellH *0.45;
self.vRenZheng = [[UILabel alloc] initWithFrame:CGRectMake(nYearOrignx - 6, vRenZhengOrignY,48,labelH)];
self.vRenZheng.textAlignment = NSTextAlignmentCenter;
self.vRenZheng.font = [UIFont systemFontOfSize:10];
self.vRenZheng.textColor = [UIColor whiteColor];
self.vRenZheng.backgroundColor = RGB(255,169,86);
[self addSubview:self.vRenZheng];
self.shopUser = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(self.shopImg.frame) + CellH*0.13,kScreenSize.width,16)];
self.shopUser.textColor = [UIColor blackColor];
self.shopUser.font = [UIFont boldSystemFontOfSize:15];
self.shopUser.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.shopUser];
self.ShopName = [[UILabel alloc] initWithFrame:CGRectMake(0,CGRectGetMaxY(self.shopUser.frame) + CellH*0.04,kScreenSize.width,16)];
self.ShopName.font = [UIFont systemFontOfSize:13];
self.ShopName.textColor = RGB(102, 102, 102);
self.ShopName.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.ShopName];
}
-(void)setItemsCorner
{
CGFloat W = self.shopImg.frame.size.height;
self.shopImg.layer.masksToBounds = YES;
self.shopImg.layer.cornerRadius = W/2;
self.shopImg.layer.borderWidth = 2;
self.shopImg.layer.borderColor = RGB(162,210, 255).CGColor;
self.province.layer.masksToBounds = YES;
self.province.layer.cornerRadius = self.province.frame.size.height/2;
self.vRenZheng.layer.masksToBounds = YES;
self.vRenZheng.layer.cornerRadius = self.vRenZheng.frame.size.height/2;
self.nYear.layer.masksToBounds = YES;
self.nYear.layer.cornerRadius = self.nYear.frame.size.height/2;
}
-(void)loadDataWith:(IfishShopInfo *)info
{
NSString*str=[NSString stringWithFormat:@"%@%@",kGetIconUrl,info.userImg];
[self.shopImg sd_setImageWithURL:[NSURL URLWithString:str]];
self.nYear.text = info.remark;
if (info.remark.length >0) {
self.nYear.hidden = NO;
}else{
self.nYear.hidden = YES;
}
NSString *str2= @"已认证";
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:str2];
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
attch.image = [UIImage imageNamed:@"businesslistings_v"];
attch.bounds = CGRectMake(0,0,9,8);
NSAttributedString *attristr=[NSAttributedString attributedStringWithAttachment:attch];
[attri insertAttributedString:attristr atIndex:0];
self.vRenZheng.attributedText = attri;
self.province.text = [NSString stringWithFormat:@"%@%@",info.shopsProvince,info.shopsCity];
if (self.province.text.length>=8) {
NSString *sub = [self.province.text substringWithRange:NSMakeRange(0,7)];
self.province.text = [NSString stringWithFormat:@"%@...",sub];
}
self.shopUser.text = info.userName;
self.ShopName.text = info.shopsName;
[self resetProvinceFrame];
}
-(void)resetProvinceFrame{
CGFloat labelH= 13;
CGFloat CellH = kScreenSize.width*0.38;
CGFloat nYearOrignx = CGRectGetMaxX(self.shopImg.frame);
CGFloat nYearOrignY =CellH *0.18;
if (self.province.text.length>4 && self.province.text.length<6) {
self.province.frame = CGRectMake(nYearOrignx - 2, nYearOrignY,60,labelH);
}else if (self.province.text.length>=6 && self.province.text.length<7){
self.province.frame = CGRectMake(nYearOrignx - 2, nYearOrignY,70,labelH);
}else if (self.province.text.length>=7 && self.province.text.length<8){
self.province.frame = CGRectMake(nYearOrignx - 2, nYearOrignY,80,labelH);
}else if (self.province.text.length>=8){
self.province.frame = CGRectMake(nYearOrignx - 2, nYearOrignY,90,labelH);
}
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end