IOS开发之UI设计---控件(UISegmentController,UISlider,UISwitch,UIActivityIndicatorView,UIProgressView)以及触摸事件(...

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;

转载于:https://www.cnblogs.com/my_work_blog_space/p/3164320.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值