// // KWMInformationVC.m // iCemarose // // Created by 陈荣科 on 16/9/26. // Copyright © 2016年 kollway. All rights reserved. // #import "KWMInformationVC.h" #import "KWMStringUtil.h" #import "KWMInformationView.h" @interface KWMInformationVC ()<UITextViewDelegate,KWMInformationViewDelegate> @property (nonatomic) KWMInformationView *vInformation; @end @implementation KWMInformationVC{ CGFloat tvHeight; UIColor *color; } +(NSString *)kwmTag{ return @"KWMInformationVC"; } - (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController setNavigationBarHidden:NO]; [self initHeaderView]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; [_vInformation removeFromSuperview]; } - (void) viewDidAppear:(BOOL)animated{ [super viewDidAppear:animated]; self.tvInformation.scrollEnabled = YES; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. [self setAutomaticallyAdjustsScrollViewInsets:NO]; self.title = _titleStr; [self initView]; } - (void)initHeaderView{ //添加頭部header _vInformation = [[KWMInformationView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 64)]; _vInformation.delegate = self; _vInformation.lbTitle.text = _titleStr; [self.view addSubview:_vInformation]; } - (void) initView{ color = [UIColor colorWithRed:244.0/255 green:245.0/255 blue:247.0/255 alpha:1]; _vBackground.backgroundColor = color; _tvInformation.backgroundColor = color; _vBottom.backgroundColor = color; _tvInformation.editable = NO; _tvInformation.showsHorizontalScrollIndicator = NO; //信息详情 CGSize size = CGSizeMake(UI_SCREEN_WIDTH - 56, 0); NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.lineSpacing = 20;// 字体的行间距 NSDictionary *attributes = @{ NSFontAttributeName:[UIFont systemFontOfSize:15], NSParagraphStyleAttributeName:paragraphStyle }; _tvInformation.attributedText = [[NSAttributedString alloc] initWithString:@"输入你的内容" attributes:attributes]; //字体高度 tvHeight = [KWMStringUtil boundingRectWithSize:size text:_inforStr testSize:15].height; tvHeight = tvHeight - UI_SCREEN_HEITHT + 162; _tvInformation.text = _inforStr; _lbTitle.text = _inforTitleStr; _tvInformation.delegate = self; //底部渐变 CAGradientLayer *gradientLy = [self shadowAsInverse]; _vBottom.layer.mask = gradientLy; } - (CAGradientLayer *)shadowAsInverse{ CAGradientLayer *newShadow = [[CAGradientLayer alloc] init]; CGRect newShadowFrame = CGRectMake(0, 0, UI_SCREEN_WIDTH,100 ); newShadow.frame = newShadowFrame; //添加渐变的颜色组合(颜色透明度的改变) newShadow.colors = [NSArray arrayWithObjects: (id)[[color colorWithAlphaComponent:0] CGColor] , (id)[[color colorWithAlphaComponent:0.1] CGColor], (id)[[color colorWithAlphaComponent:0.5] CGColor], (id)[[color colorWithAlphaComponent:0.7] CGColor], (id)[[color colorWithAlphaComponent:0.9] CGColor], nil]; return newShadow; } #pragma mark -- KWMInformationViewDelegate - (void)kwm_backToLastVC{ [self.navigationController popViewControllerAnimated:YES]; } @end