1、直接上代码:
unsigned int count = 0;
Ivar *members = class_copyIvarList([UIPageControl class], &count);
for (int i = 0; i < count; i++)
{
Ivar var = members[i];
const char *memberAddress = ivar_getName(var);
const char *memberType = ivar_getTypeEncoding(var);
NSLog(@"address = %s ; type = %s",memberAddress,memberType);
}
log:
address = _lastUserInterfaceIdiom ; type = q
address = _indicators ; type = @"NSMutableArray"
address = _currentPage ; type = q
address = _displayedPage ; type = q
address = _pageControlFlags ; type = {?="hideForSinglePage"b1"defersCurrentPageDisplay"b1}
address = _currentPageImage ; type = @"UIImage"
address = _pageImage ; type = @"UIImage"
address = _currentPageImages ; type = @"NSMutableArray"
address = _pageImages ; type = @"NSMutableArray"
address = _backgroundVisualEffectView ; type = @"UIVisualEffectView"
address = _currentPageIndicatorTintColor ; type = @"UIColor"
address = _pageIndicatorTintColor ; type = @"UIColor"
address = _legibilitySettings ; type = @"_UILegibilitySettings"
address = _numberOfPages ; type = q
2、简单的应用场景:
获取UIPageControl
的属性,然后修改小原点的的图片,kvc+runtime。这样比较方便,当然自定义UIPageControl
也是可以的。
UIImage *image = [UIImage imageNamed:@"line1"];
UIImage *image2 = [UIImage imageNamed:@"line2"];
UIPageControl *pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 100, 400, 20)];
pageControl.numberOfPages = 5;
pageControl.currentPage = 0;
[pageControl setValue:image forKey:@"_pageImage"];
[pageControl setValue:image2 forKey:@"_currentPageImage"];
[self.view addSubview:pageControl];
效果: