IOS UI 第六篇:基本UI
加两个UI模块
{
[self begin1];
[self begin2];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-(void)begin1{
UIActivityIndicatorView *viView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
viView.center = CGPointMake(160, 300);
viView.color = [UIColor blueColor];
viView.hidesWhenStopped = NO;
[viView startAnimating];
[viView stopAnimating];
[self.view addSubview:viView];
}
-(void)begin2{
UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 200, 50)];
mySwitch.onTintColor = [UIColor redColor];
mySwitch.on = NO;
[mySwitch setOn:YES animated:YES];
[mySwitch addTarget:self action:@selector(onButton:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:mySwitch];
}
-(void)onButton:(id)sender{
NSLog(@":::%@", sender);
UISwitch *sw = sender;
if(sw.on) NSLog(@"ON");
else NSLog(@"OFF");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
if(textField.text.length >= 6 && !range.length)
return NO;
return YES;
}
NSLog(@"%d-%d-%d",range.length, range.location, textField.text.length);
if (textField == self.nameTextField) {
if(textField.text.length >= 6 && !range.length)
return NO;
return YES;
}
if (textField == self.passwordTextField){
if(textField.text.length >= 4 && !range.length)
return NO;
return YES;
}
return YES;
}
//将输入框取消第一响应者,键盘就睡自动收回
[self.nameTextField resignFirstResponder];
[self.passwordTextField resignFirstResponder];
}
//在销毁的时候将自己在通知中心中移除
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
NSLog(@"textFiled 键盘的return键被点击");
[textField resignFirstResponder];
NSLog(@"开始搜索!!!");
return YES;
}
@property (strong, nonatomic) IBOutlet UIView *subView;
@property (nonatomic, assign)float red;
@property (nonatomic, assign)float blue;
@property (nonatomic, assign)float green;
@property (nonatomic, assign)float alpha;
@property (weak, nonatomic) IBOutlet UILabel *redLabel;
@property (weak, nonatomic) IBOutlet UILabel *greenLabel;
@property (weak, nonatomic) IBOutlet UILabel *blueLabel;
@property (weak, nonatomic) IBOutlet UILabel *alphaLabel;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
_redLabel.text = [NSString stringWithFormat:@"%%50"];
_blueLabel.text = [NSString stringWithFormat:@"%%50"];
_greenLabel.text = [NSString stringWithFormat:@"%%50"];
_alphaLabel.text = [NSString stringWithFormat:@"%%50"];
_red = _green = _blue = _alpha = 0.5;
self.subView.backgroundColor = [UIColor colorWithRed:_red green:_green blue:_blue alpha:_alpha];
// Do any additional setup after loading the view, typically from a nib.
UISlider *slide = [[UISlider alloc] initWithFrame:CGRectMake(10, 300, 300, 60)];
slide.minimumValue = 0;
slide.maximumValue = 1;
[slide setValue:0.5 animated:YES];
[slide addTarget:self action:@selector(onSliderChange:) forControlEvents:UIControlEventValueChanged];
//[self.view addSubview:slide];
}
-(void)onSliderChange:(id)sender{
NSLog(@"slider:%@", sender);
UISlider *slider = sender;
self.subView.alpha = slider.value;
}
- (IBAction)blueSlider:(id)sender {
UISlider *slider = sender;
_blue = slider.value;
_blueLabel.text = [NSString stringWithFormat:@"%%%.0lf", slider.value*100];
self.subView.backgroundColor = [UIColor colorWithRed:_red green:_green blue:_blue alpha:_alpha];
}
- (IBAction)greenSlider:(id)sender {
UISlider *slider = sender;
_green = slider.value;
_greenLabel.text = [NSString stringWithFormat:@"%%%.0lf", slider.value*100];
self.subView.backgroundColor = [UIColor colorWithRed:_red green:_green blue:_blue alpha:_alpha];
}
- (IBAction)redSlider:(id)sender {
UISlider *slider = sender;
_red = slider.value;
_redLabel.text = [NSString stringWithFormat:@"%%%.0lf", slider.value*100];
self.subView.backgroundColor = [UIColor colorWithRed:_red green:_green blue:_blue alpha:_alpha];
}
- (IBAction)alphaSlider:(id)sender {
UISlider *slider = sender;
_alpha = slider.value;
_alphaLabel.text = [NSString stringWithFormat:@"%%%.0lf", slider.value*100];
self.subView.backgroundColor = [UIColor colorWithRed:_red green:_green blue:_blue alpha:_alpha];
}
{
[self begin1];
[self begin2];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
-(void)begin1{
UIActivityIndicatorView *viView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
viView.center = CGPointMake(160, 300);
viView.color = [UIColor blueColor];
viView.hidesWhenStopped = NO;
[viView startAnimating];
[viView stopAnimating];
[self.view addSubview:viView];
}
-(void)begin2{
UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 200, 50)];
mySwitch.onTintColor = [UIColor redColor];
mySwitch.on = NO;
[mySwitch setOn:YES animated:YES];
[mySwitch addTarget:self action:@selector(onButton:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:mySwitch];
}
-(void)onButton:(id)sender{
NSLog(@":::%@", sender);
UISwitch *sw = sender;
if(sw.on) NSLog(@"ON");
else NSLog(@"OFF");
}
UIView *redView;
CGPoint beginPoint;
BOOL canMove;
BOOL mark;
}
- (void)viewDidLoad
{
[super viewDidLoad];
redView=[[UIView alloc]initWithFrame:CGRectMake(-320, 0, 320, 480)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
mark = 0;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark--
#pragma mark touch事件
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//任意取出一个touch对象
UITouch *touch = touches.anyObject;
beginPoint = [touch locationInView:self.view];
NSLog(@"mark = %d", mark);
if(mark == 0){
if (beginPoint.x<20) {
canMove=YES;
}else{
canMove=NO;
}
}
if(mark){
if (beginPoint.x]]]]>300) {
canMove=YES;
}else{
canMove=NO;
}
}
NSLog(@"触摸开始 %f,%f---",beginPoint.x,beginPoint.y);
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = touches.anyObject;
CGPoint movePoint = [touch locationInView:self.view];
NSLog(@"触摸滑动 %f",movePoint.x-beginPoint.x);
if (canMove && mark == 0) {
redView.frame=CGRectMake(-320+movePoint.x-beginPoint.x, 0, 320, 480);
}
if( canMove && mark == 1){
redView.frame=CGRectMake(movePoint.x - 320 , 0, 320, 480);
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸结束");
UITouch *touch = touches.anyObject;
CGPoint endPoint = [touch locationInView:self.view];
if(mark == 0){
if ((endPoint.x-beginPoint.x)>200) {
[UIView animateWithDuration:0.25 animations:^{
redView.frame=CGRectMake(0, 0, 320, 480);
}];
mark = 1;
}else{
[UIView animateWithDuration:0.25 animations:^{
redView.frame=CGRectMake(-320, 0, 320, 480);
}];
}
}
else if(mark == 1){
NSLog(@"duanyulei");
if ((320 - endPoint.x)<20) {
[UIView animateWithDuration:0.25 animations:^{
redView.frame=CGRectMake(-320, 0, 320, 480);
}];
mark = 0;
}else{
[UIView animateWithDuration:0.25 animations:^{
redView.frame=CGRectMake(0, 0, 320, 480);
}];
}
}
}
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"触摸取消");
}
- (IBAction)showAlertView:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *showActionSheet;
- (IBAction)showActionSheet:(id)sender;
@end
@implementation QFViewController{
UIAlertView *alertView;
UIActionSheet *actionSheet;
}
- (void)viewDidLoad
{
[super viewDidLoad];
alertView=[[UIAlertView alloc]initWithTitle:@"通知" message:@"明天礼拜五了,大家晚上多多努力,争取在放假前把项目上架。" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil,nil];
actionSheet=[[UIActionSheet alloc]initWithTitle:@"你确定删除么?" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showAlertView:(id)sender {
[alertView show];
}
- (IBAction)showActionSheet:(id)sender {
[actionSheet showInView:self.view];
}
#pragma mark--
#pragma mark UIAlertView代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"点击了第%d个按键",buttonIndex);
switch (buttonIndex) {
case 0:
break;
default:
break;
}
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"点击了第%d个按键",buttonIndex);
switch (buttonIndex) {
case 0:
break;
default:
break;
}
}
IOS UI 第六篇:基本UI的更多相关文章
- IOS设计模式第六篇之适配器设计模式
版权声明:原创作品,谢绝转载!否则将追究法律责任. 那么怎么使用适配器设计模式呢? 这个之前提到的水平滚动的视图像这样: 为了开始实现他,我们创建一个新的继承与UIView的HorizontalScr ...
- IOS UI 第八篇:基本UI
实现图片的滚动,并且自动停止在每张图片上 - (void)viewDidLoad{ [super viewDidLoad]; UIScrollView *scrollView = [[U ...
- iOS进阶指南试读之UI篇
iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...
- 四核驱动的三维导航—淘宝新UI(设计篇)
前面有一篇博客说到了淘宝UWP的"四核驱动的三维导航—淘宝新UI(需求分析篇)",花了两周的时间实现了这个框架,然后又陆陆续续用了三周的时间完善它. 多窗口导航,与传统的导航方式的 ...
- 游戏模块分析总结(2)之UI、操作篇
转自:http://www.gameres.com/309812.html 游戏模块分析总结(2)之UI.操作篇 发布者: wuye | 发布时间: 2014-12-12 15:03| 评论数: 0 ...
- WPF案例 (六) 动态切换UI布局
原文:WPF案例 (六) 动态切换UI布局 这个Wpf示例对同一个界面支持以ListView或者CardView的布局方式呈现界面,使用控件ItemsControl绑定数据源,使用DataTempla ...
- 环信 之 iOS 客户端集成四:集成UI
在Podfile文件里加入 pod 'EaseUI', :git => 'https://github.com/easemob/easeui-ios-cocoapods.git' 然后在终端中的 ...
- WPF 精修篇 非UI进程后台更新UI进程
原文:WPF 精修篇 非UI进程后台更新UI进程 <Grid> <Grid.RowDefinitions> <RowDefinition Height="11* ...
- 第六章 consul UI
1.建立三个consul节点(一个server+两个client) 具体的过程见http://www.cnblogs.com/java-zhao/p/5375132.html 1)在终端下启动vagr ...
随机推荐
- 比float更好的页面布局inline-block
一:页面布局的发展过程 桌格设计 表格+css div+css的浮动布局 div+css的内联块布局 二:流行多年的浮动布局的优劣 优势: div+css浮动布局的优势,主要是相对于table布局来说 ...
- JavaScript的类型、值和变量的总结
前言:JavaScript的数据类型分为两类:原始类型和对象类型.5种原始类型:数字.字符串.布尔值.null(空).undefined(未定义).对象是属性的集合,每个属性都由“名/值对”(值可以是 ...
- tortoisegit使用密钥连接服务器(转)
目录 [hide] 1 使用putty的密钥 1.1 生成putty密钥 2 在服务器上添加openssh公钥 3 在tortoisegit上使用密钥 4 putty密钥与openssh密钥转化 5 ...
- 十天学Linux内核之第三天---内存管理方式
原文:十天学Linux内核之第三天---内存管理方式 昨天分析的进程的代码让自己还在头昏目眩,脑子中这几天都是关于Linux内核的,对于自己出现的一些问题我会继续改正,希望和大家好好分享,共同进步.今 ...
- HBase加Solr
HBase加Solr 如何解决分布式系统数据事务一致性问题 (HBase加Solr) 摘要:对于所有的分布式系统,我想事务一致性问题是极其非常重要的问题,因为它直接影响到系统的可用性.本文以下所述所要 ...
- [Network]Introduction and Basic concepts
[该系列是检讨计算机网络知识.因为现在你想申请出国.因此,在写这篇博客系列的大多数英语.虽然英语,但大多数就是我自己的感受和理解,供大家学习和讨论起来] 1 Network Edge The devi ...
- 馋-c语言的规则
在记者采访过程,有着c的认识的情况,有时会被问到有关字符搭配以及运算先后顺序的问题,比方a+++++b的值.++i+++i+++i+i的值等类似的,这都属于c的符号方面的问题.那么如何才干轻而易举的去 ...
- GCD(1222)Wolf and Rabbit
Problem Description There is a hill with n holes around. The holes are signed from 0 to n-1. A rabbi ...
- 注册 集 与 删除 -- C
文章3位设置和清除操作. #include <stdio.h> #include <stdlib.h> #include <string.h> #define BI ...
- JavaEE Tutorials (2) - 使用教程示例
2.1 必要软件27 2.1.1 Java EE 7软件开发包28 2.1.2 Java平台标准版28 2.1.3 Java EE 7教程组件28 2.1.4 NetBeans IDE29 2.1.5 ...