IOS Study Notes (4)

Source: Internet
Author: User

Use UISlider to create a slide for the specified range and place it in the view of the attempt controller. @ Interface SliderView: UIViewController @ property (non atomic, strong) UISlider * mySlider; @ end @ synthesize mySlider;-(void) viewDidLoad {[super viewDidLoad]; self. view. backgroundColor = [UIColor whiteColor]; self. mySlider = [[UISlider alloc] initWithFrame: CGRectMake (0.0f, 0.0f, 200366f, 23.0f)]; self. mySlider. center = self. view. center; self. mySlider. minimumValue = 0.0f; // the minimum value of the selected range self. mySlider. maximumValue = 10010000f; // select the maximum self in the range. mySlider. value = self. mySlider. maximumValue/2.0; // current value self. mySlider. continuous = NO; // The default value is YES. If YES, the slider d target is called continuously when thumb slides. [Self. mySlider addTarget: self action: @ selecter (sliderValueChanged :) forControlEvents: UIControlEventValueChanged]; [self. view addSubView: self. mySlider];} the slider on the slider is called thumb; target-(void) sliderValueChanged :( UISlider *) paramSender {if ([paramSender isEqual: self. mySlider]) {NSLog (@ "% @", paramSender. value) ;}} select setThumbImage: forState: Method UIControlStateNormal from the thumb image of slider. // thumb in normal state is not clicked. UIControlStateHighlighted // The selected thumb, that is, the image displayed when you click thumb [self. mySlider setThumbImage: [UIImage imaged: @ "ThumbNormal.png"] forState: UIControlStateNormal]; [self. mySlider setThumbImage: [UIImage imaged: @ "success"] forState: Success]; UISegmentedControl: simple option grouping @ interface SegmentedControl: UIViewController @ property (non atomic, strong) UISegmentedControl * mySegmentedControl; @ end; @ synthesize mySegmentedControl;-(void) viewDidLoad {[super viewDidLoad]; self. view. backgrounderColor = [UIColor whiteColor]; NSArray * segments = [[NSArray alloc] initWithObjects: @ "iPhone", @ "iPad", nil]; self. mySegmentedControl = [[UISegmentedControl alloc] initWithItems: segments]; self. mySegmentedControl. center = self. view. center; [self. view addSubview: self. mySegmentedControl];}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.