是否可以在頁面視圖控制器本機指示器上添加自定義圖像頁面指示器?是否可以在頁面視圖控制器本機指示器上添加自定義圖像頁面指示器?
如果可能,請幫助我該怎麼做?
this is the reference image not the actual one
是否可以在頁面視圖控制器本機指示器上添加自定義圖像頁面指示器?是否可以在頁面視圖控制器本機指示器上添加自定義圖像頁面指示器?
如果可能,請幫助我該怎麼做?
this is the reference image not the actual one
如果你平時想改變指示器的顏色,那麼你可以直接改變顏色,也沒有必要通過這種方式
let pageVC = UIPageControl()
pageVC.currentPageIndicatorTintColor = UIColor.red
pageVC.tintColor = UIColor.green
改變形象,但你想改變的PageIndicator
圖像然後嘗試此鏈接: -
答案與GrayPageControl: - Is there a way to change page indicator dots color
它真的很好,可靠。我也使用過這個代碼。
您可能需要做一些更多的定製作爲
-(void) updateDots
{
for (int i = 0; i < [self.subviews count]; i++)
{
UIImageView* dot = [self.subviews objectAtIndex:i];
if (i == self.currentPage) {
if(i==0) {
dot.image = [UIImage imageNamed:@"activesearch.png"];
} else {
dot.image = activeImage;
}
} else {
if(i==0) {
dot.image = [UIImage imageNamed:@"inactivesearch.png"];
} else {
dot.image = inactiveImage;
}
}
}
}
希望它會幫助你
UIImageView * dot = [self.subviews objectAtIndex:i]; 我可以知道這個代碼用於什麼嗎? –
它是PageIndicator imageView –
是的,我可以知道。但是什麼和爲什麼我們使用這個? [self.subviews objectAtIndex:i] –
如果你有網頁控制裁判,然後使用
let pageControl = UIPageControl.appearanceWhenContainedInInstancesOfClasses([ViewController.self])
pageControl.pageIndicatorTintColor = UIColor.lightGrayColor()
pageControl.currentPageIndicatorTintColor = UIColor.darkGrayColor()
你可以改變指示劑的顏色根據你的圖像 –