有没有办法在我的第一页中使用UIPageControl添加一个放大镜图标来执行一些搜索,而不是使用点作为标记?我在iPhone上的本机应用程序中尝试了谷歌搜索,但没有找到类似的问题,但它看起来像是苹果应用程序中广泛使用的功能。有人能给我提供建议帮助吗?
_indicators
的数组,其中包含每个点的UIView。这个数组是一个私有属性,所以你不应该去修改它。如果你需要自定义图标,你将需要自己实现页面指示器。@interface EPCPageControl : UIPageControl
@property (nonatomic) UIImage *lastPageImage;
@end
@implementation EPCPageControl
- (void)setNumberOfPages:(NSInteger)pages
{
[super setNumberOfPages:pages];
if (pages > 0) {
UIView *indicator = [self.subviews lastObject];
indicator.backgroundColor = [UIColor clearColor];
if (indicator.subviews.count == 0) {
UIImageView *icon = [[UIImageView alloc] initWithImage:self.lastPageImage];
icon.alpha = 0.5;
icon.tag = 99;
[indicator addSubview:icon];
}
}
}
- (void)setCurrentPage:(NSInteger)page
{
[super setCurrentPage:page];
if (self.numberOfPages > 1 && self.lastPageImage) {
UIView *indicator = [self.subviews lastObject];
indicator.backgroundColor = [UIColor clearColor];
UIImageView *icon = (UIImageView *)[indicator viewWithTag:99];
icon.alpha = (page > 1 && page == self.numberOfPages-1) ? 1.0 : 0.5;
}
}