pmusolino / PMAlertController

PMAlertController is a great and customizable alert that can substitute UIAlertController
MIT License
2.52k stars 187 forks source link

Add functions to customize the alert title and description font and color #3

Closed barnaclejive closed 8 years ago

barnaclejive commented 8 years ago

Actions extend UIButton and do not anything additional to customize. However, the alert itself has no way to customize the Title and Description font and color.

pmusolino commented 8 years ago

Thanks for the pull request. However I do not think this is necessary.

You can access to the properties declared inside PMAlertController. In this way, you can customize everything of the components inside it: title, description, image, buttons.

Like this:

    let alertVC = PMAlertController(title: "Locate your device", description: "Enables access to your location: discover what you can do when you're traveling and what is available near you.", image: UIImage(named: "flag.png"), style: .Alert)

    //Add action
    alertVC.addAction(PMAlertAction(title: "Cancel", style: .Cancel, action: { () -> Void in
        print("Cancel")
    }))

    //Add action and customize it
    let actionAllow = PMAlertAction(title: "Allow", style: .Default, action: { () in
        print("Allow")
    })
    actionAllow.setTitleColor(UIColor.blueColor(), forState: .Normal)
    alertVC.addAction(actionAllow)

    //Customize alert title
    alertVC.alertTitle.font = (UIFont(name: "ArialMT", size: 40))

    self.presentViewController(alertVC, animated: true, completion: nil)

Result: simulator screen shot 19 mag 2016 10 10 16

Let me know. If all is clear, please close this pull request. Thanks :)

barnaclejive commented 8 years ago

That makes sense, however, when using PMAlertController via CocoaPods those labels are not accessible. If exposing them is the intended way to customize them, they will need to be marked public.

pmusolino commented 8 years ago

Thank you very much for the suggestion @barnaclejive, i've updated the project and now there is a new version 1.0.1