1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// 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