ios-小知识点-自定义uislider
//左右轨的图片 UIImage *stetchLeftTrack= [UIImage imageNamed:@"brightness_bar.png"]; UIImage *stetchRightTrack = [UIImage imageNamed:@"brightness_bar.png"]; //滑块图片 UIImage *thumbImage = [UIImage imageNamed:@"mark.png"]; UISlider *sliderA=[[UISlider alloc]initWithFrame:CGRectMake(30, 320, 257, 7)]; sliderA.backgroundColor = [UIColor clearColor]; sliderA.value=1.0; sliderA.minimumValue=0.7; sliderA.maximumValue=1.0; [sliderA setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal]; [sliderA setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal]; //注意这里要加UIControlStateHightlighted的状态,否则当拖动滑块时滑块将变成原生的控件 [sliderA setThumbImage:thumbImage forState:UIControlStateHighlighted]; [sliderA setThumbImage:thumbImage forState:UIControlStateNormal]; //滑块拖动时的事件 [sliderA addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged]; //滑动拖动后的事件 [sliderA addTarget:self action:@selector(sliderDragUp:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:sliderA];
1.这里只记录一些学习笔记
2.这里只记录一些学习心得,如果心得方向有错,请留言
2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)