码迷,mamicode.com
首页 > 其他好文 > 详细

UIActionSheet UISlider 的简单使用

时间:2015-08-17 20:00:32      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:

//  Created by 妖精的尾巴 on 15-8-17.

//  Copyright (c) 2015 妖精的尾巴. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()<UIAlertViewDelegate,UIActionSheetDelegate>


@end


@implementation ViewController


- (void)viewDidLoad

{

    [super viewDidLoad];

    /**

     *请在这里调用下面UI控件的方法

     */

    

}

-(void)viewDidAppear:(BOOL)animated

{

  [self createActionSheet];

}

-(void)createActionSheet

{

    UIActionSheet* actSheet=[[UIActionSheet alloc]initWithTitle:@"想念是蓝色的" delegate:self cancelButtonTitle:@"确定" destructiveButtonTitle:@"删除" otherButtonTitles:@"取消", nil];

    [actSheet showInView:self.view];

   }

-(void)createAlter

{

    UIAlertView* alter=[[UIAlertView alloc]initWithTitle:@"爱的国度" message:@"天青色等烟雨,而我在等你,你会在哪里?" delegate:self cancelButtonTitle:@"等你在彼岸" otherButtonTitles:@"灵犀湖畔", nil];

    [alter show];

}

-(void)defineSlider

{

    //自定义slider

    UISlider* slider=[[UISlider alloc]initWithFrame:CGRectMake(50, 80, 250, 20)];

    slider.minimumTrackTintColor=[UIColor greenColor];

    slider.maximumTrackTintColor=[UIColor redColor];

    slider.minimumValue=0;

    slider.maximumValue=100;

    [self.view addSubview:slider];

}


-(void)createSlider

{

    UISlider* slider=[[UISlider alloc]initWithFrame:CGRectMake(100, 100, 200,10)];

    [self.view addSubview:slider];

    slider.minimumValue=0;

    slider.maximumValue=1;

    slider.value=0.1;

    [slider addTarget:self action:@selector(changedValue:) forControlEvents:UIControlEventValueChanged];

}


-(void)changedValue:(UISlider*)slider

{

    NSLog(@"%.2f",slider.value);

}

#pragma mark - UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

    if (buttonIndex==0) {

        NSLog(@"宛在水中央");

    }

    else{

        NSLog(@"渭水河畔");

    }

}

#pragma mark - UIActionSheetDelegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

    if (buttonIndex==0) {

        NSLog(@"我会告诉你这是真的");

    }

    else if (buttonIndex==1)

    {

         NSLog(@"因为你的心是透明的");

    }

    else

    {

        NSLog(@"盛开在花海");

    }


}



UIActionSheet UISlider 的简单使用

标签:

原文地址:http://my.oschina.net/iOSliuhui/blog/493597

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!