Onboard icon indicating copy to clipboard operation
Onboard copied to clipboard

Swift example!!

Open Dershowitz011 opened this issue 8 years ago • 8 comments

Could you please give an example in swift please? :(

Dershowitz011 avatar May 31 '16 19:05 Dershowitz011

// Initialize onboarding view controller
var onboardingVC = OnboardingViewController()

// Create slides
let firstPage = OnboardingContentViewController.contentWithTitle("Welcome To The App!", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut.", image: UIImage(named: "image1"), buttonText: nil, action: nil)

let secondPage = OnboardingContentViewController.contentWithTitle("Step 1", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut.", image: UIImage(named: "image2"), buttonText: nil, action: nil)

let thirdPage = OnboardingContentViewController.contentWithTitle("Step 2:", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut.", image: UIImage(named: "image3"), buttonText: nil, action: nil)

let fourthPage = OnboardingContentViewController.contentWithTitle("Step 3", body: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent ut.", image: UIImage(named: "image4"), buttonText: nil, action: nil)

// Define onboarding view controller properties
onboardingVC = OnboardingViewController.onboardWithBackgroundImage(UIImage(named: "background.jpg"), contents: [firstPage, secondPage, thirdPage, fourthPage])
onboardingVC.shouldFadeTransitions = true
onboardingVC.shouldMaskBackground = false
onboardingVC.shouldBlurBackground = false
onboardingVC.fadePageControlOnLastPage = true
onboardingVC.pageControl.pageIndicatorTintColor = UIColor.darkGrayColor()
onboardingVC.pageControl.currentPageIndicatorTintColor = UIColor.whiteColor()
onboardingVC.skipButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
onboardingVC.allowSkipping = false
onboardingVC.fadeSkipButtonOnLastPage = true

// Present presentation
self.presentViewController(onboardingVC, animated: true, completion: nil)

Someone let me know if I should add this as a pull request

rcobelli avatar Jun 16 '16 20:06 rcobelli

@rcobelli Quick question...what did you have to import and did you just put all this inside viewDidLoad in your ViewController?

ahadsheriff avatar Jun 17 '16 08:06 ahadsheriff

I added #import "OnboardingViewController.h" to my bridging header. Within my ViewController, I didn't have to import anything.

All this code is within a function that I call from viewDidAppear (where I check NSUserDefaults)

rcobelli avatar Jun 17 '16 15:06 rcobelli

might have to add $(PROJECT_DIR)/Pods to your User Header Search Paths

markdrayton247 avatar Jul 11 '16 18:07 markdrayton247

I made an example .maybe its help link

nazrdogan avatar Jan 12 '17 08:01 nazrdogan

@nazrdogan still want a swift demo .i just want a project.thx

ninevcat avatar Apr 07 '17 12:04 ninevcat

@themachine15 I made quick example link

nazrdogan avatar Apr 07 '17 16:04 nazrdogan

Swift 4

var onboardingVC = OnboardingViewController()

        let firstPage = OnboardingContentViewController(title: "Page Title", body: "Page body goes here.", image: UIImage(named: "steam.png"), buttonText: "Textff For Button") { () -> Void in
            // do something here when users press the button, like ask for location services permissions, register for push notifications, connect to social media, or finish the onboarding process
        }
        
        
        let secondPage = OnboardingContentViewController(title: "Page Title", body: "Pafqege body goes here.", image: UIImage(named: "palestine.png"), buttonText: "Tzext For Button") { () -> Void in
            // do something here when users press the button, like ask for location services permissions, register for push notifications, connect to social media, or finish the onboarding process
        }
        
        
        onboardingVC = OnboardingViewController(backgroundImage: UIImage(named: "steam.png"), contents: [firstPage, secondPage])
        
        onboardingVC.shouldBlurBackground = true
        
        self.present(onboardingVC, animated: true, completion: nil)

omarshamali avatar Jun 03 '18 18:06 omarshamali