UIKit 手写控件转换大小写
2015-11-11 00:00
281 查看
//
// ViewController.m
// 手写转换大小写
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 30, 200, 30)];
label.text=@"要转化的字母";
label.font=[UIFont fontWithName:@"Arial" size:15];
[self.view addSubview:label];
UILabel *labelI = [[UILabel alloc]initWithFrame:CGRectMake(20, 90, 200, 30)];
labelI.text=@"转化后的字母";
labelI.font=[UIFont fontWithName:@"Arial" size:15];
[self.view addSubview:labelI];
_output = [[UILabel alloc]initWithFrame:CGRectMake(120, 90, 200, 30)];
// _output.backgroundColor=[UIColor blueColor];
[self.view addSubview:_output];
_input = [[UITextField alloc]initWithFrame:CGRectMake(120, 30, 200, 30)];
_input.borderStyle=UITextBorderStyleLine;
_input.textAlignment=NSTextAlignmentCenter;
_input.placeholder=@"请输入内容";
[self.view addSubview:_input];
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(120, 130, 70, 30)];
[button setTitle:@"转大写" forState:UIControlStateNormal];
[button addTarget:self action:@selector(Upper) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor =[UIColor blueColor];
[button.layer setBorderWidth:1.0];
[self.view addSubview:button];
UIButton *buttonI = [[UIButton alloc]initWithFrame:CGRectMake(220, 130, 70, 30)];
[buttonI setTitle:@"转小写" forState:UIControlStateNormal];
[buttonI addTarget:self action:@selector(Lower) forControlEvents:UIControlEventTouchUpInside];
buttonI.backgroundColor =[UIColor blueColor];
[buttonI.layer setBorderWidth:1.0];
[self.view addSubview:buttonI];
}
-(void)Upper{
NSString *upper = _input.text;
_output.text=[upper uppercaseString];
}
-(void)Lower{
NSString *lower = _output.text;
_output.text=[lower lowercaseString];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.h
// 手写转换大小写
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic,strong) UITextField *input;
@property(nonatomic,strong) UILabel *output;
-(void)Upper;
-(void)Lower;
@end
// ViewController.m
// 手写转换大小写
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 30, 200, 30)];
label.text=@"要转化的字母";
label.font=[UIFont fontWithName:@"Arial" size:15];
[self.view addSubview:label];
UILabel *labelI = [[UILabel alloc]initWithFrame:CGRectMake(20, 90, 200, 30)];
labelI.text=@"转化后的字母";
labelI.font=[UIFont fontWithName:@"Arial" size:15];
[self.view addSubview:labelI];
_output = [[UILabel alloc]initWithFrame:CGRectMake(120, 90, 200, 30)];
// _output.backgroundColor=[UIColor blueColor];
[self.view addSubview:_output];
_input = [[UITextField alloc]initWithFrame:CGRectMake(120, 30, 200, 30)];
_input.borderStyle=UITextBorderStyleLine;
_input.textAlignment=NSTextAlignmentCenter;
_input.placeholder=@"请输入内容";
[self.view addSubview:_input];
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(120, 130, 70, 30)];
[button setTitle:@"转大写" forState:UIControlStateNormal];
[button addTarget:self action:@selector(Upper) forControlEvents:UIControlEventTouchUpInside];
button.backgroundColor =[UIColor blueColor];
[button.layer setBorderWidth:1.0];
[self.view addSubview:button];
UIButton *buttonI = [[UIButton alloc]initWithFrame:CGRectMake(220, 130, 70, 30)];
[buttonI setTitle:@"转小写" forState:UIControlStateNormal];
[buttonI addTarget:self action:@selector(Lower) forControlEvents:UIControlEventTouchUpInside];
buttonI.backgroundColor =[UIColor blueColor];
[buttonI.layer setBorderWidth:1.0];
[self.view addSubview:buttonI];
}
-(void)Upper{
NSString *upper = _input.text;
_output.text=[upper uppercaseString];
}
-(void)Lower{
NSString *lower = _output.text;
_output.text=[lower lowercaseString];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
//
// ViewController.h
// 手写转换大小写
//
// Created by 非凡程序员 on 15/11/11.
// Copyright (c) 2015年 Querida. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic,strong) UITextField *input;
@property(nonatomic,strong) UILabel *output;
-(void)Upper;
-(void)Lower;
@end
相关文章推荐
- Request对象
- 常用控件—UILabel
- Range Sum Query
- MiniGui3.0.12在主机上的配置及在开发板上的移植
- IOS UIImageView
- leetcode之Range Sum Query - Immutable
- UEFI Console Splitter 2nd
- Looper.myLooper().quit() 报 NullPointerException
- 进击的KFC:UI(一)UIView及其子类
- 爬爬爬之路:UI(一) UIView UILabel
- [TwistedFate]UIView UILabel
- UI学习第一天UIView 和UILabel
- hdu1159 Common Subsequence (最长公共子序列)
- 我的iOS学习历程 - UIView和UILabel
- 我的iOS学习历程 - UIView和UILabel
- 新手学EasyUI(七)----DataGrid CheckBox 动态选中
- UI第一天UIView
- UI基础知识 -- UIView UILabel
- UI基础-UIView及其子类
- 小技巧9-iOS UITextField结束编辑、收回键盘