月別アーカイブ: 2015年11月

templateによるpage-based applicationにPageControlを表示(SWIFT版)

templateにより、page-based applicationを作成。

ModelControllerに以下追加

//
//-------------------------------------------------------------
    func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int
    {
        return self.pageData.count
    }
    func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int
    {
        return 0
    }
//-------------------------------------------------------------
//

RootViewControllerを以下一部修正

//
        self.pageViewController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil)
//

PageControlの色等変更については、AppDelegateに以下追加

//
@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
        //-------------------------------------------------------------
        let pageControl = UIPageControl.appearance()
        
        pageControl.pageIndicatorTintColor = UIColor.lightGrayColor()
        
        pageControl.currentPageIndicatorTintColor = UIColor.blackColor()
        
        pageControl.backgroundColor = UIColor.whiteColor()
        //-------------------------------------------------------------
   
    return YES;
}
//