006 在Xcode4.5上创建IOS6.0应用 (按钮,开关控件,滑块控件,分段控件,工具栏)

IOS的按钮的使用

在IOS上使用按钮控件特别简单,而且有很多非常绚丽的效果

首先我们来看两张图片第一张是通过上面的按钮控制下面的两个按钮是否可以的情况


对按钮的设置特别简单,只要操作公具就可以完成上面的效果


上面的Show Touch On Highlight 属性是设置按钮是否在点击的时候有高亮的效果
下面来看看按钮的状态切换是如何实现的

ViewController.h

@interface ViewController : UIViewController{
    IBOutlet UIButton * clearButton;
    IBOutlet UIButton * smallButton;
}

@property(nonatomic,retain)UIButton * clearButton;
@property(nonatomic,retain)UIButton * smallButton;

-(IBAction)disableBut:(id)sender;
@end


ViewController.m
@implementation ViewController

@synthesize clearButton;
@synthesize smallButton;


-(IBAction)disableBut:(id)sender{
    if (clearButton.enabled == YES) {
        clearButton.enabled = NO;
        smallButton.enabled = NO;
        [((UIButton *) sender) setTitle:@"Enable" forState:(UIControlStateNormal)];
    }else{
        clearButton.enabled = YES;
        smallButton.enabled = YES;
        [((UIButton *) sender) setTitle:@"Disable" forState:(UIControlStateNormal)];
    }
}


- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)dealloc
{
    [clearButton release];
    [smallButton release];
    [super dealloc];
}

@end


注意:

[((UIButton *) sender) setTitle:@"Enable" forState:(UIControlStateNormal)];

这一句中的forState属性中的选择有多个是一个枚举类型的变量具体的选择如下(出自帮助文档)





IOS的开关的使用


IOS的滑块的使用



注意:判断滑块的最大值




IOS的分段控件的使用

分段控件的使用基本与前面的控件相同
在使用时如何获得控件的那一段被选中
方法
-(IBAction)handleSegment:(id)sender{
UISegmentedControl * myseg = (UISegmentedControl * )sender;
//通过myseg.selectedSegmentIndex对象的这个属性来判断是控件的那一段被选中
}

IOS的工具栏的使用

工具栏的使用也特别方便如下图就可以看出工具栏的使用


注意和工具栏配合使用的控件有如下




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shuaiyinoo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值