UISegmentedControl (paging Controller) AND UISlider (slider Controller)
- -(Void) viewDidLoad
- {
- [Super viewDidLoad];
-
- UIImageView * animatedImageView = [[UIImageView alloc] initWithFrame: CGRectMake (60, 80,200,300)];
- AnimatedImageView. backgroundColor = [UIColor redColor];
- AnimatedImageView. tag = 100;
- [Self. view addSubview: animatedImageView];
- [AnimatedImageView release];
-
- NSMutableArray * arrayImages = [NSMutableArray array];
- For (int I = 1; I <8; I ++ ){
-
- [ArrayImages addObject: [UIImage imageNamed: [NSString stringWithFormat: @ "huoju _ % I. tiff", I];
-
- }
- // Add a series of images to achieve the animation effect
- AnimatedImageView. animationImages = arrayImages;
-
- # Pragma mark-segment controller
- // InitWithItems: You can add images or strings.
- UISegmentedControl * segment = [[UISegmentedControl alloc] initWithItems: @ [@ "statr", @ "stop", @ "HMT"];
- Segment. frame = CGRectMake (10, 20,300, 40 );
- // Segment
- NSLog (@ "% lu", segment. numberOfSegments );
- // Whether to display the highlighted state (NO) or instantly highlighted (YES) at the time of Selection)
- Segment. momentary = YES;
- [Segment addTarget: self action: @ selector (onClickSegmentedControl :) forControlEvents: UIControlEventValueChanged];
- // Set the section with the subscript of 2 to not clickable
- [Self. view addSubview: segment];
- [Segment release];
-
-
- // Sliding Controller
- UISlider * slider = [[UISlider alloc] initWithFrame: CGRectMake (10,500,300, 40)];
- Slider. maximumValue = 3;
- Slider. minimumValue = 0.1;
- NSLog (@ "% f", slider. value );
- [Self. view addSubview: slider];
- [Slider release];
- [Slider addTarget: self action: @ selector (changeSliderValue :) forControlEvents: UIControlEventValueChanged];
-
- }
-
-
- -(Void) onClickSegmentedControl :( UISegmentedControl *) segmented {
-
- // SelectedSegmentIndex
- If (segmented. selectedSegmentIndex = 0 ){
- // Start the animation
- [(UIImageView *) [self. view viewWithTag: 100]) startAnimating];
-
- } Else {
- // Stop the animation
- [(UIImageView *) [self. view viewWithTag: 100]) stopAnimating];
-
- }
- }
-
- -(Void) changeSliderValue :( UISlider *) sLider {
-
- // Increase or decrease the speed through the sliding control
- (UIImageView *) [self. view viewWithTag: 100]). animationDuration = sLider. value;
- [(UIImageView *) [self. view viewWithTag: 100]) startAnimating];
- }
-
-
- -(Void) didReceiveMemoryWarning
- {
- [Super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }