zoukankan      html  css  js  c++  java
  • IOS开发之UI设计---控件(UISegmentController,UISlider,UISwitch,UIActivityIndicatorView,UIProgressView)以及触摸事件(UITouch)

    UISegmentedControl:(多段选择器)

    NSArray *arr = [NSArrayarrayWithObjects:@"Lucy",@"Lily",@"OK", nil];

        UISegmentedControl *segCtrl = [[UISegmentedControlalloc]initWithItems:arr];

        [segCtrl setFrame:CGRectMake(0, 0, 210, 40)];

        [segCtrl addTarget:selfaction:@selector(click:) forControlEvents:UIControlEventValueChanged];

        [self.view addSubview:segCtrl];

        [segCtrl release];

     

    //手动插入一个segmentedControl

    - (void)insertSegmentWithTitle:(NSString *)title atIndex:(NSUInteger)segment animated:(BOOL)animated; // insert before segment number. 0..#segments. value pinned

    - (UIView *)viewWithTag:(NSInteger)tag;  // recursive search. includes self 从视图上获取tag为某个值的视图

     

    //进度条

    UISlider *slider = [[UISlideralloc]initWithFrame:CGRectMake(0, 40, 240, 30)];

        [slider addTarget:segCtrl action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];

        slider.tag = 2;

        slider.maximumValue = 100;

        slider.minimumValue = 0;

        [self.view addSubview:slider];

        [slider release];

     

     

    //开关

    UISwitch *_switch = [[UISwitchalloc]initWithFrame:CGRectMake(0, 80, 50, 30)];

        [_switch addTarget:self action:@selector(switchChange:) forControlEvents:UIControlEventValueChanged];

        [self.view addSubview:_switch];

        _switch.thumbTintColor = [UIColor purpleColor];

        //设置UISwitch的背景色

        _switch.tintColor = [UIColor cyanColor];

        _switch.onTintColor = [UIColor brownColor];

        [_switch release];

     

    //环形进度条

    UIActivityIndicatorView *acView = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

        /*UIActivityIndicatorViewStyleWhiteLarge,

         UIActivityIndicatorViewStyleWhite,

         UIActivityIndicatorViewStyleGray,

         */

        [acView setFrame:CGRectMake(0, 120, 60, 30)];

        acView.tag = 5;

        acView.hidesWhenStopped = YES;//设置停止转圈后,隐藏

        [self.view addSubview:acView];

        [acView release];

     

    //进度条(推荐使用)

    UIProgressView *proView = [[UIProgressViewalloc]initWithProgressViewStyle:UIProgressViewStyleDefault];

        [proView setFrame:CGRectMake(0, 170, 260, 20)];

        proView.tag = 6;

        proView.progress = 1.0;

        [proView setProgressTintColor:[UIColorredColor]];

        [proView setTrackTintColor:[UIColorblueColor]];

        [self.view addSubview:proView];

        [proView release];

     

     

    //步进器每一次都增加或者减少一个特定的值

    UIStepper *step = [[UIStepperalloc]initWithFrame:CGRectMake(0, 200, 60, 30)];

        [step addTarget:selfaction:@selector(stepChanged:) forControlEvents:UIControlEventValueChanged];// 事件状态UIControlEventValueChanged 

        step.minimumValue = 0; //步进器的最小值

        step.maximumValue = 100;//步进器的最大值

        step.stepValue = 5;//每一步增加或者减少的值

        step.wraps = YES; //是否循环

      

    UITouch : NSObject

     

    - (CGPoint)locationInView:(UIView *)view; //当前视图在屏幕中所处的位置

    - (CGPoint)previousLocationInView:(UIView *)view; //

     

    UITextView : UIScrollView

     

     

    //导入第三方库文件

    //_textView设置一个圆角边

    //控件边框的颜色

        _textView.layer.borderColor = [UIColorblackColor].CGColor;

        //设置控件边框圆角弧度

        _textView.layer.cornerRadius = 8.0;

        //设置控件边框线条宽度

        _textView.layer.borderWidth = 2.0;

     

    UITextViewDelegate:

    - (BOOL)textViewShouldBeginEditing:(UITextView *)textView;

    - (BOOL)textViewShouldEndEditing:(UITextView *)textView;

     

    - (void)textViewDidBeginEditing:(UITextView *)textView;

    - (void)textViewDidEndEditing:(UITextView *)textView;

     

    - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;

  • 相关阅读:
    Tomcat/ WebSphere/WebLogic的作用和特点
    Servlet 执行时一般实现哪几个方法?
    synchronized 和 java.util.concurrent.locks.Lock 的异同 ?
    Request 对象的主要方法
    char 型变量中能不能存贮一个中文汉字?为什么?
    描述一下 JVM 加载 class 文 件的原理机制?
    单例设计模式
    Thread和Runnable
    Math.round方法、String实例化
    思路清晰的秘诀:结构化思维(自上而下)
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3164320.html
Copyright © 2011-2022 走看看