最近无意间发现大部分app轮播图的UIPageController 的风格都变了,变成扁平的,觉得挺好看;然后自己也想实现一个
但是后来发现,自定义一个比较麻烦,就想着看看网上有没有好的三方实现了这个效果😶,然后找到了SDCycleScrollView.但是发现其中也是使用自定义的TAPageControl来实现切换图片的,
//MARK: 打印pageController的所有属性
- (void)getAllIvarList{
unsigned int methodCount = 0;
Ivar * ivars = class_copyIvarList([UIPageControl class], &methodCount);
for (unsigned int i = 0; i < methodCount; i ++) {
Ivar ivar = ivars[i];
const char * name = ivar_getName(ivar);
const char * type = ivar_getTypeEncoding(ivar);
NSLog(@"UIPageControl拥有的成员变量的类型为%s,名字为 %s ",type, name);
}
free(ivars);
}
那么一切都是那么理所当然了
_customCellScrollViewDemo = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 820, w, 120) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
//SDCycleScrollView 自带属性实现自定义pageController
// _customCellScrollViewDemo.currentPageDotImage = [UIImage imageNamed:@"YES"];
// _customCellScrollViewDemo.pageDotImage = [UIImage imageNamed:@"NO"];
_customCellScrollViewDemo.imageURLStringsGroup = imagesURLStrings;
//获取pageController属性,修改图片
UIPageControl * pageControl = [_customCellScrollViewDemo valueForKey:@"pageControl"];
[pageControl setValue:[UIImage imageNamed:@"YES"] forKey:@"_currentPageImage"];
[pageControl setValue:[UIImage imageNamed:@"NO"] forKey:@"_pageImage"];
[demoContainerView addSubview:_customCellScrollViewDemo];
最后实现的效果,和SDCycleScrollView自定义的效果是一样的