ifish/Ifish/controllers/IfishYooseeFile/IfishYooseeControlller/yooseFishTankView/YseeCollectionCell/FishControlSecondCell.m

64 lines
1.9 KiB
Objective-C

//
// FishControlSecondCell.m
// Ifish
//
// Created by imac on 16/6/29.
// Copyright © 2016年 lianxiang. All rights reserved.
//
#import "FishControlSecondCell.h"
@implementation FishControlSecondCell
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
self.templabel = [[UILabel alloc] init];
[self addSubview:self.templabel];
UIView *shuLine=[[UIView alloc] initWithFrame:CGRectMake(self.frame.size.width - 1,0, 1, self.frame.size.height)];
shuLine.backgroundColor = JWUIColorFromRGB(0xdddddd);
[self addSubview:shuLine];
UIView *hengLine=[[UIView alloc] initWithFrame:CGRectMake(0,self.frame.size.height -1,self.frame.size.width, 1)];
hengLine.backgroundColor = shuLine.backgroundColor = JWUIColorFromRGB(0xdddddd);
[self addSubview:hengLine];
}
return self;
}
-(void)setTemWith:(NSString *)temp{
NSString* formattemp = [NSString stringWithFormat:@"%@°C",temp];
if (!temp) {
formattemp = @"暂无数据";
}
NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc] initWithString:formattemp ];
[attributedString addAttribute:NSForegroundColorAttributeName value:RGB(253, 188, 63) range:NSMakeRange(0,[formattemp length])];
if (temp) {
[attributedString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:37] range:NSMakeRange(0, [formattemp length]-2)];
}
self.templabel.textAlignment = NSTextAlignmentCenter;
[self.templabel setAttributedText:attributedString];
CGFloat templabelW =self.frame.size.width - 5*2;
CGFloat templabelH = self.frame.size.height - 10*2;
self.templabel.frame = CGRectMake(self.frame.size.width/2-templabelW/2, self.frame.size.height/2-templabelH/2, templabelW, templabelH);
}
@end