// // mallRuleController.m // ThePaperBase // // Created by Huixin on 15/10/30. // Copyright © 2015年 scar1900. All rights reserved. // #import "mallRuleController.h" @interface mallRuleController () @property(nonatomic, strong)UIScrollView *backView; @property(nonatomic, strong)UILabel *contentLabel; @property(nonatomic, strong)UILabel *timeLabel; //@property(nonatomic, strong)UITextView *contentView; @end @implementation mallRuleController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.titleStr = @"商城使用规则"; self.view.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; [self.view addSubview:self.backView]; [self.backView addSubview:self.contentLabel]; [self.backView addSubview:self.timeLabel]; [self layoutViews]; [Remote doJsonAction:1 requestUrl:mallRuleURL parameter:nil delegate:self]; } - (void)layoutViews { [self.backView makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view).with.insets(UIEdgeInsetsMake(self.barHeight, 0, 0, 0)); }]; [self.contentLabel makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.backView.top).offset(15); make.left.equalTo(self.backView.left).offset(10); make.right.equalTo(self.view.right).offset(-10); make.height.mas_equalTo(@0); }]; [self.timeLabel makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentLabel.bottom).offset(15); make.left.equalTo(self.backView.left).offset(10); make.right.equalTo(self.view.right).offset(-10); make.height.mas_equalTo(@18); }]; } - (UIScrollView*)backView { if (!_backView) { _backView = [[UIScrollView alloc] init]; _backView.backgroundColor = [UIColor clearColor]; _backView.alwaysBounceVertical = YES; _backView.directionalLockEnabled = YES; _backView.scrollEnabled = YES; } return _backView; } - (UILabel*)contentLabel { if (!_contentLabel) { _contentLabel = [[UILabel alloc] init]; _contentLabel.backgroundColor = [UIColor clearColor]; _contentLabel.textColor = [UIColor colorWithHexString:TextBlack]; _contentLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _contentLabel.numberOfLines = 0; _contentLabel.hidden = YES; } return _contentLabel; } - (UILabel*)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.backgroundColor = [UIColor clearColor]; _timeLabel.textColor = [UIColor colorWithHexString:TextBlack]; _timeLabel.font = appFont(TEXT_THREE_LEVELSIZE, NO); _timeLabel.textAlignment = NSTextAlignmentRight; _timeLabel.hidden = YES; } return _timeLabel; } //- (UITextView*)contentView { // if (!_contentView) { // _contentView = [UITextView new]; // _contentView.backgroundColor = [UIColor colorWithHexString:BackGroundColor]; // _contentView.font = appFont(TEXT_THREE_LEVELSIZE, NO); // _contentView.textColor = [UIColor colorWithHexString:TextBlack]; // } // return _contentView; //} #pragma mark - remote delegate - (void)remoteResponsSuccess:(int)actionTag withResponsData:(id)responseData { self.titleStr = responseData[@"title"]; NSString *string = responseData[@"content"]; // [self.view addSubview:self.contentView]; // [self.contentView makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.naviBar.bottom); // make.left.equalTo(self.view.left).offset(10); // make.right.equalTo(self.view.right).offset(-10); // make.bottom.equalTo(self.view.bottom); // }]; // NSAttributedString *attributedStr = getLineSpaceAttributedString(string, 7, self.contentView.font); // self.contentView.attributedText = attributedStr; NSAttributedString *attributedStr = getLineSpaceAttributedString(string, 7, self.contentLabel.font); CGFloat height = heightForAttributeStringWithLabel(attributedStr, rect_screen.size.width-20, self.contentLabel.font); [self.backView setContentSize:CGSizeMake(rect_screen.size.width, height+63)]; self.contentLabel.attributedText = attributedStr; [self.contentLabel remakeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.backView.top).offset(15); make.left.equalTo(self.backView.left).offset(10); make.right.equalTo(self.view.right).offset(-10); make.height.mas_equalTo(height); }]; self.contentLabel.hidden = NO; self.timeLabel.text = responseData[@"updateTime"]; self.timeLabel.hidden = NO; } - (void)remoteResponsFailed:(int)actionTag withMessage:(NSString *)message resultCode:(NSString *)code { ShowTextMessage(message); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end