iOS
来源:互联网 发布:admin.seo.com.cn 编辑:程序博客网 时间:2024/06/05 11:13
#import "FeedBackViewController.h"#import <Masonry.h>#define KCColor(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]//颜色宏定义#define KCGrayColor KCColor(204,204,204)#define KCGreenColor KCColor(32,153,133)#define KCWhiteColor KCColor(250,249,245)@interface FeedBackViewController () <UITextViewDelegate, UINavigationControllerDelegate>@property (nonatomic, strong) UITextView *feedBackTextView;@property (nonatomic, strong) UIButton *commitButton;@property (nonatomic, strong) UILabel *placeHolderLabel;@property (nonatomic, strong) UILabel *stringLengthLabel;@end@implementation FeedBackViewController#pragma mark ------------------------------life circle------------------------------------ (void)viewDidLoad { [super viewDidLoad]; [self initFeedBackText]; [self initButton]; // Do any additional setup after loading the view.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}#pragma mark -----------------------------private method----------------------------------(void) initFeedBackText{ _feedBackTextView = [[UITextView alloc] init]; self.feedBackTextView.delegate = self; _feedBackTextView.backgroundColor = [UIColor whiteColor]; _feedBackTextView.font = [UIFont systemFontOfSize:14]; self.automaticallyAdjustsScrollViewInsets = NO; [self.view addSubview:self.feedBackTextView]; [self.feedBackTextView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake([UIScreen mainScreen].bounds.size.width, 150)); make.top.equalTo(self.view.mas_top).offset(64); make.centerX.equalTo(self.view.mas_centerX); }]; _placeHolderLabel = [[UILabel alloc] init]; _placeHolderLabel.text = @"欢迎留下您的反馈"; _placeHolderLabel.textColor = KCGrayColor; _placeHolderLabel.font = [UIFont systemFontOfSize:14]; self.placeHolderLabel.userInteractionEnabled = NO; [self.view addSubview:self.placeHolderLabel]; [self.placeHolderLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.view.mas_left).offset(16); make.top.equalTo(self.feedBackTextView.mas_top).offset(16); }];_stringLengthLabel = [[UILabel alloc] init]; _stringLengthLabel.textColor = KCGrayColor; _stringLengthLabel.text = @"100"; _stringLengthLabel.font = [UIFont systemFontOfSize:12]; [self.view addSubview:self.stringLengthLabel]; [self.stringLengthLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.view.mas_right).offset(-16); make.bottom.equalTo(self.feedBackTextView.mas_bottom).offset(-10); }];}-(void) initButton{ _commitButton = [[UIButton alloc] init]; [_commitButton setTitle:@"提交" forState:UIControlStateNormal]; [_commitButton setTitleColor:KCWhiteColor forState:UIControlStateNormal]; _commitButton.titleLabel.font = [UIFont systemFontOfSize:17]; _commitButton.backgroundColor = KCGrayColor; _commitButton.layer.cornerRadius = 7; self.commitButton.userInteractionEnabled = NO; [self.commitButton addTarget:self action:@selector(commitButtonClicked) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:self.commitButton]; [self.commitButton mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(320, 40)); make.top.equalTo(self.feedBackTextView.mas_bottom).offset(174); make.centerX.equalTo(self.view.mas_centerX); }];}#pragma mark -----------------------------textView delegate-----------------------------------(void) textViewDidChange:(UITextView *)textView{ self.placeHolderLabel.hidden = YES; self.commitButton.backgroundColor = KCGreenColor; self.commitButton.userInteractionEnabled = YES; self.stringLengthLabel.text = [NSString stringWithFormat:@"%lu", (unsigned long)(100 - textView.text.length)]; if (textView.text.length >= 100) { textView.text = [textView.text substringToIndex:100]; self.stringLengthLabel.text = @"0"; } if (textView.text.length == 0) { self.placeHolderLabel.hidden = NO; self.commitButton.userInteractionEnabled = NO; self.commitButton.backgroundColor = KCGrayColor; }}@end
参考:http://blog.csdn.net/yj_sail/article/details/52254278
0 0
- iOS
- iOS
- IOS
- iOS
- iOS
- IOS
- ios
- iOS
- iOS
- IOS
- iOS
- ios
- ios ~~~~~
- ios
- IOS
- IOS
- IOS
- ios
- IO流_如何让对象的成员变量不被序列化
- PAT (Advanced Level) Practise 1001 A+B Format
- Android注册界面之Md5对用户信息加密
- 算法课不定期心得整理——一些递归式的求解心得
- java自学之路(Java从入门到精通)
- iOS
- JavaMail——基础篇
- 自己看一些零散源码的小结
- Python--lambda表达式学习
- Git核心用法
- 小C实例也有大梦想——巧用强制类型转换
- java 中类初始化,构造方法,静态成员变量,静态块的加载顺序
- 在win10,64位下安装mysql-5.7.17-winx64解压版
- SpringMVC数据校验、文件上传