//程序員
// ViewController.mide
// 手寫轉換大小寫atom
//spa
// Created by 非凡程序員 on 15/11/11..net
// Copyright (c) 2015年 Querida. All rights reserved.3d
//orm
#import "ViewController.h"get
@interface ViewController ()input
@end it
@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