Commit 2e89dba8 cgx

意见反馈输入文字限制

1 个父辈 a6300c29
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
self.tabBar.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG); self.tabBar.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
// 设置tabbar选中及未选中的文字颜色 // 设置tabbar选中及未选中的文字颜色
self.tabBar.tintColor = ColorFromHex(0x62C3D5); self.tabBar.tintColor = BrandColor;
self.tabBar.unselectedItemTintColor = SubTitleColor; self.tabBar.unselectedItemTintColor = SubTitleColor;
// 设置tabbaritem图片渲染模式 // 设置tabbaritem图片渲染模式
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
if (!_dealView) { if (!_dealView) {
_dealView = [UIView new]; _dealView = [UIView new];
UIButton *closeBtn = [UIButton btnWithTitle:@"注销" titleColor:ColorFromHex(0x62C3D5) font:BoldFont(15) bgColor:DSClearColor]; UIButton *closeBtn = [UIButton btnWithTitle:@"注销" titleColor:BrandColor font:BoldFont(15) bgColor:DSClearColor];
[closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside]; [closeBtn addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
[_dealView addSubview:closeBtn]; [_dealView addSubview:closeBtn];
......
...@@ -20,6 +20,7 @@ static int AlbumColumnCount = 4; ...@@ -20,6 +20,7 @@ static int AlbumColumnCount = 4;
@property (strong, nonatomic) UILabel *redLab; @property (strong, nonatomic) UILabel *redLab;
@property (assign, nonatomic) int unreadCount; @property (assign, nonatomic) int unreadCount;
@property (strong, nonatomic) UITextView *feedTV; @property (strong, nonatomic) UITextView *feedTV;
@property (strong, nonatomic) UILabel *wordLimitLab;
@property (strong, nonatomic) UICollectionView *imgCollectionView; @property (strong, nonatomic) UICollectionView *imgCollectionView;
@property (strong, nonatomic) UIButton *commitBtn; @property (strong, nonatomic) UIButton *commitBtn;
@end @end
...@@ -43,6 +44,7 @@ static int AlbumColumnCount = 4; ...@@ -43,6 +44,7 @@ static int AlbumColumnCount = 4;
[self setNaviRightItem]; [self setNaviRightItem];
[self.view addSubview:self.feedTV]; [self.view addSubview:self.feedTV];
[self.view addSubview:self.wordLimitLab];
[self.view addSubview:self.imgCollectionView]; [self.view addSubview:self.imgCollectionView];
[self.view addSubview:self.commitBtn]; [self.view addSubview:self.commitBtn];
...@@ -67,6 +69,26 @@ static int AlbumColumnCount = 4; ...@@ -67,6 +69,26 @@ static int AlbumColumnCount = 4;
#pragma mark - UITextViewDelegate #pragma mark - UITextViewDelegate
- (void)textViewDidEndEditing:(UITextView *)textView { - (void)textViewDidEndEditing:(UITextView *)textView {
textView.text = [NSString trimString:textView.text]; textView.text = [NSString trimString:textView.text];
[self dealWorldLimitAttTextWithChangeLength:(int)textView.text.length];
}
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
int textLength = (int)(textView.text.length - range.length + text.length);
[self dealWorldLimitAttTextWithChangeLength:textLength];
if (textLength > 400) { return NO; }
return YES;
}
- (void)dealWorldLimitAttTextWithChangeLength:(int)changeLength {
NSString *changeStr = [NSString stringWithFormat:@"%d", changeLength];
NSString *fixStr = @"/400";
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", changeStr, fixStr]];
UIColor *changeColor = changeLength > 400 ? ColorFromHex(0xF04B77) : BrandColor;
[attStr addAttribute:NSForegroundColorAttributeName value:changeColor range:NSMakeRange(0, changeStr.length)];
UIColor *fixColor = [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? SmallTextColor : DarkTextColor;
[attStr addAttribute:NSForegroundColorAttributeName value:fixColor range:NSMakeRange(changeStr.length, fixStr.length)];
self.wordLimitLab.attributedText = attStr;
} }
#pragma mark - 品牌模式 #pragma mark - 品牌模式
...@@ -296,6 +318,15 @@ static int AlbumColumnCount = 4; ...@@ -296,6 +318,15 @@ static int AlbumColumnCount = 4;
return _feedTV; return _feedTV;
} }
- (UILabel *)wordLimitLab {
if (!_wordLimitLab) {
_wordLimitLab = [UILabel labWithFont:SysFont(12)];
_wordLimitLab.textAlignment = NSTextAlignmentRight;
[self dealWorldLimitAttTextWithChangeLength:0];
}
return _wordLimitLab;
}
- (UICollectionView *)imgCollectionView { - (UICollectionView *)imgCollectionView {
if (!_imgCollectionView) { if (!_imgCollectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
...@@ -373,6 +404,11 @@ static int AlbumColumnCount = 4; ...@@ -373,6 +404,11 @@ static int AlbumColumnCount = 4;
make.bottom.equalTo(self.view).offset(-91); make.bottom.equalTo(self.view).offset(-91);
make.size.mas_equalTo(CGSizeMake(155, 40)); make.size.mas_equalTo(CGSizeMake(155, 40));
}]; }];
[self.wordLimitLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.feedTV).offset(-8);
make.bottom.equalTo(self.feedTV).offset(-15);
make.width.equalTo(@200);
}];
} }
@end @end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!