开发者

Increasing the UIPageControl Size in iOS

开发者 https://www.devze.com 2023-01-20 14:14 出处:网络
Hi I want to incease the size of UIPAgeControl on iOS... on google i\'ve found this http://www.onidev.com/200开发者_开发技巧9/12/02/customisable-uipagecontrol/

Hi I want to incease the size of UIPAgeControl on iOS... on google i've found this http://www.onidev.com/200开发者_开发技巧9/12/02/customisable-uipagecontrol/

was wondering is there any other way....?


I used this code:

Source: http://apptech.next-munich.com/2010/04/customizing-uipagecontrols-looks.html

// header
@interface StyledPageControl : UIPageControl { }

@end

// implementation
@implementation StyledPageControl

- (void) setCurrentPage:(NSInteger)page {
 [super setCurrentPage:page];

 NSString* imgActive = [[NSBundle mainBundle] pathForResource:IMG_PAGE_ACTIVE ofType:nil];
 NSString* imgInactive = [[NSBundle mainBundle] pathForResource:IMG_PAGE_INACTIVE ofType:nil];
 for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) {
  UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];
  if (subviewIndex == page) [subview setImage:[UIImage imageWithContentsOfFile:imgActive]];
  else [subview setImage:[UIImage imageWithContentsOfFile:imgInactive]];
 }
}

- (void) setNumberOfPages:(NSInteger)pages {
 [super setNumberOfPages:pages];

 NSString* img = [[NSBundle mainBundle] pathForResource:IMG_PAGE_INACTIVE ofType:nil];
 for (NSUInteger subviewIndex = 0; subviewIndex < [self.subviews count]; subviewIndex++) {
  UIImageView* subview = [self.subviews objectAtIndex:subviewIndex];
  [subview setImage:[UIImage imageWithContentsOfFile:img]];
 }
}

@end
0

精彩评论

暂无评论...
验证码 换一张
取 消