无法更改UIPageControl中的currentPage属性

时间:2016-02-11 10:15:21

标签: swift uipagecontrol

private func setupPageControl() {
    let appearance = UIPageControl.appearance()
    appearance.pageIndicatorTintColor = UIColor.grayColor()
    appearance.currentPageIndicatorTintColor = UIColor.whiteColor()
    appearance.backgroundColor = UIColor.darkGrayColor()
    appearance.currentPage = 2
}

我正在尝试在我的应用中更改UIPageControl的第一个位置,但是我无法通过此代码获得适当的结果。

1 个答案:

答案 0 :(得分:0)

您正在尝试通过外观代理设置currentPage,这显然不会也不应该有效。

以与页面控件属性/变量相同的方式设置属性,使其起作用。

要知道哪些选择器应该与外观代理一起使用,请检查班级' Objective-C头文件并查找UI_APPEARANCE_SELECTOR属性

UIPageControl.h

相关问题