Guest User

Untitled

a guest
May 26th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. - (void)applicationDidFinishLaunching:(UIApplication *)application {
  2.  
  3. CGRect frame = CGRectMake(0.0, 200.0, 320, 40);
  4. pageControl = [[UIPageControl alloc] initWithFrame:frame];
  5. [pageControl addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventTouchUpInside];
  6. pageControl.backgroundColor = [UIColor grayColor];
  7. pageControl.numberOfPages = 10;
  8.  
  9. [window addSubview:pageControl];
  10. [window makeKeyAndVisible];
  11.  
  12. [self updateControlImages];
  13. }
  14.  
  15. -(void)updateControlImages{
  16.  
  17. for (UIImageView *view in [pageControl subviews]){
  18. if ([[[view class] description] isEqualToString:@"UIImageView"]) {
  19. view.frame = CGRectMake(view.frame.origin.x, view.frame.origin.y, 15, 15);
  20. [view setImage:[UIImage imageNamed:@"smileyFace.png"]];
  21. }
  22. }
  23. // this sets the image for the current page
  24. [[[pageControl subviews] objectAtIndex:[pageControl currentPage]] setImage:[UIImage imageNamed:@"smileyFace2.png"]];
  25. }
  26.  
  27.  
  28. - (void)pageAction:(id)sender
  29. {
  30. [self updateControlImages];
  31. }
Add Comment
Please, Sign In to add comment