• iOS中的分段控件(UISegmentedControl)和滑块控件(UISlider)


    #import "RootViewController.h"
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        //分段控件
        //1.创建控件
        /*
        NSArray *items = @[@"轻拍",@"长按",@"清扫",@"平移",@"捏合",@"旋转"];
        UISegmentedControl *segControl = [[UISegmentedControl alloc] initWithItems:items];
        segControl.frame = CGRectMake(10, 100, 300, 30);
    //给控件添加target/ action 设计模式 给控件添加事件 [segControl addTarget:self action:@selector(handleSegControl:) forControlEvents:UIControlEventValueChanged]; //设置默认选中的分段 segControl.selectedSegmentIndex = 2; //设置分段上显示的文字 [segControl setTitle:@"大胸美" forSegmentAtIndex:2]; segControl.tintColor = [UIColor grayColor]; //设置分段控件的渲染颜色 [segControl setWidth:70 forSegmentAtIndex:2]; //2.添加到父视图 [self.view addSubview:segControl]; //3.释放 [segControl release];
    */ //滑块控件 //1.创建控件 /* UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(10, 300, 300, 30)]; //设置滑竿最小值 slider.minimumValue = 0.0; //设置滑竿最大值 slider.maximumValue = 1.0; //添加响应是事件 [slider addTarget:self action:@selector(handleSlider:) forControlEvents:UIControlEventValueChanged]; //设置响应事件是否在滑动的过程中连续触发 slider.continuous = NO; //2.添加到父视图 [self.view addSubview:slider]; //3.释放 [slider release]; */ //图片对象 UIImage *image = [UIImage imageNamed:@"iphone.png"]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; imageView.frame = CGRectMake(30, 30, 260, 260/image.size.width*image.size.height); //播放动态图片 NSMutableArray *imageArray = [NSMutableArray arrayWithCapacity:1]; for (int i = 1; i <= 30; i++) { NSString *imageName = [NSString stringWithFormat:@"2250_3650903_179fb89ae279fae-%d(被拖移).tiff",i]; UIImage *image = [UIImage imageNamed:imageName]; //iamge对象添加到imageArray上 [imageArray addObject:image]; } imageView.animationImages = imageArray; //设置播放一组动画的时间 imageView.animationDuration = 0.8; //设置重复的次数 //imageView.animationRepeatCount = 1; //2.开始播放 [imageView startAnimating]; //打开用户交互,默认是关闭的,UILabel的用户交互也是关闭的. imageView.userInteractionEnabled = YES; [self.view addSubview:imageView]; [imageView release]; /* //基本的控制对象,如按钮和滑块的基类 UIControl UITextField UIButton UISegmentedControl UISlider UISwitch UIStepper UIGestureRecognizer */ // UIResponder } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma 滑竿响应事件 - (void)handleSlider:(UISlider *)slider { NSLog(@"%.2f",slider.value); } #pragma mark --handle segment control - (void)handleSegControl:(UISegmentedControl *)segmentControl{ switch ( segmentControl.selectedSegmentIndex) { case 0: NSLog(@"轻拍"); break; case 1: NSLog(@"长按"); break; case 2: NSLog(@"清扫"); break; case 3: NSLog(@"平移"); break; case 4: NSLog(@"捏合"); break; case 5: NSLog(@"旋转"); break; default: break; } } @end
  • 相关阅读:
    线段树----hdoj 1754 I here it
    树状数组----poj 2352 stars
    莫队算法
    枚举+深搜----poj 3279 Fliptile
    java 10 -09的作业
    java 09 06 thread-同步代码块-同步方法
    java09-05 join_daemon
    java09 02 Thread-yield 放弃
    java 07 jar
    java 08 作业
  • 原文地址:https://www.cnblogs.com/wohaoxue/p/4764761.html
Copyright © 2020-2023  润新知