SDCycleScrollView使用起来非常便利,可能一些小细节会自己的需求不符,在不修改源代码的情况下项目中做了调整来满足UI需求,记录下一下。
解决分页控件不能靠右问题
[[self.adScrollView valueForKeyPath:@"_pageControl"] addObserver:self forKeyPath:@"hidden" options:NSKeyValueObservingOptionNew context:nil];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if([keyPath isEqualToString:@"hidden"]) {
UIControl *pageControl = [self.adScrollView valueForKeyPath:@"_pageControl"];
CGRect frame = pageControl.frame;
frame.origin.x = 15;
pageControl.frame = frame;
}
}
// 注销监听
- (void)dealloc{
[[self.adScrollView valueForKeyPath:@"_pageControl"] removeObserver:self forKeyPath:@"hidden"];
}
解决背景图片不能铺满问题
UIImageView *backgroundImageView = [cycleScrollView valueForKeyPath:@"_backgroundImageView"];
backgroundImageView.contentMode = UIViewContentModeScaleToFill;