step 1.create a new project(iOS8 or iOS 9).
step 2.pod install.
var coachMarksController: CoachMarksController?
let avatarText = "That's your profile picture. You look gorgeous!"
let profileSectionText = "You are in the profile section, where you can review all your informations."
let handleText = "That, here, is your name. Sounds a bit generic, don't you think?"
let emailText = "This is your email address. Nothing too fancy."
let postsText = "Here, is the number of posts you made. You are just starting up!"
let reputationText = "That's your reputation around here, that's actually quite good."
let nextButtonText = "Ok!"
//MARK: - View lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.coachMarksController = CoachMarksController()
self.coachMarksController?.allowOverlayTap = true
self.coachMarksController?.datasource = self
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.coachMarksController?.startOn(self)
}
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
let image = info[UIImagePickerControllerOriginalImage] as! UIImage
imageView.image = image
picker.dismissViewControllerAnimated(true, completion: nil)
}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {
picker.dismissViewControllerAnimated(true, completion: nil)
}
///
//MARK: - Protocol Conformance | CoachMarksControllerDataSource
func numberOfCoachMarksForCoachMarksController(coachMarksController: CoachMarksController) -> Int {
return 5
}
func coachMarksController(coachMarksController: CoachMarksController, coachMarksForIndex index: Int) -> CoachMark {
switch(index) {
case 0:
return coachMarksController.coachMarkForView(self.imageView)
case 1:
return coachMarksController.coachMarkForView(self.imageView)
case 2:
return coachMarksController.coachMarkForView(self.imageView)
case 3:
return coachMarksController.coachMarkForView(self.imageView)
case 4:
return coachMarksController.coachMarkForView(self.imageView)
default:
return coachMarksController.coachMarkForView()
}
}
func coachMarksController(coachMarksController: CoachMarksController, coachMarkViewsForIndex index: Int, coachMark: CoachMark) -> (bodyView: CoachMarkBodyView, arrowView: CoachMarkArrowView?) {
let coachViews = coachMarksController.defaultCoachViewsWithArrow(true, arrowOrientation: coachMark.arrowOrientation)
switch(index) {
case 0:
coachViews.bodyView.hintLabel.text = self.profileSectionText
coachViews.bodyView.nextLabel.text = self.nextButtonText
case 1:
coachViews.bodyView.hintLabel.text = self.handleText
coachViews.bodyView.nextLabel.text = self.nextButtonText
case 2:
coachViews.bodyView.hintLabel.text = self.emailText
coachViews.bodyView.nextLabel.text = self.nextButtonText
case 3:
coachViews.bodyView.hintLabel.text = self.postsText
coachViews.bodyView.nextLabel.text = self.nextButtonText
case 4:
coachViews.bodyView.hintLabel.text = self.reputationText
coachViews.bodyView.nextLabel.text = self.nextButtonText
default: break
}
return (bodyView: coachViews.bodyView, arrowView: coachViews.arrowView)
}
@IBAction func addPhoto(sender: AnyObject) {
let picker = UIImagePickerController()
picker.sourceType = .SavedPhotosAlbum
picker.delegate = self
picker.allowsEditing = false
picker.navigationBarHidden = true
picker.modalPresentationStyle = .CurrentContext
self.presentViewController(picker, animated: true, completion: nil)
}