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;

  • 相关阅读:
    让PictureBox支持URL显示图片
    .NET HttpWebRequest/WebClient网络请求第一次很慢解决方案
    SQL 存储过程 分页查询
    LookUpEditPopup自动调整宽度
    安装DotNetCore.1.0.0-VS2015Tools.Preview2失败解决方案
    数据库附加或还原后用户权限问题
    visual studio插件开发dll类库免加全局缓存处理办法
    GZAPI框架初识
    洛谷 P2678 跳石头
    洛谷 P1097 统计数字
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3164320.html
Copyright © 2011-2022 走看看