Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I customize ViewController with your Presentr #4

Closed
iHunterX opened this issue Jul 1, 2016 · 6 comments
Closed

How can I customize ViewController with your Presentr #4

iHunterX opened this issue Jul 1, 2016 · 6 comments
Assignees
Milestone

Comments

@iHunterX
Copy link

iHunterX commented Jul 1, 2016

No description provided.

@danlozano
Copy link
Contributor

You can present any custom View Controller you create either through code, xibs or interface builder.

Are you referring to the AlertViewController I include in the framework? If so, it is currently only customizable in that you can supply the title text, body text and 1 or 2 buttons which have a title, an action block and a style, which can be .Default, .Destructive or .Cancel, which use green, red or gray text color.

What kinds of things would you like to be able to customize on the AlertViewController? I could look into adding this in the next release.

@danlozano danlozano self-assigned this Jul 1, 2016
@iHunterX
Copy link
Author

iHunterX commented Jul 4, 2016

I mean how can I change the sizes, frames of the pop up, thanks

@danlozano
Copy link
Contributor

Oh, got it!

Right now the only presentation types (which deal with sizing and positioning the presented controller on screen) are the 4 included. Popup, Alert, TopHalf and BottomHalf.

My idea was that that would be enough for the typical cases, and any other case which I missed could be added on via a pull request by someone else.

But, it might be a good idea to have a "Custom" presentation type, which allows you to set the set the size and position, without having to change code inside the framework.

I like this idea. Will get working on this for the next release.

@danlozano danlozano added this to the Next Release milestone Jul 4, 2016
@danlozano
Copy link
Contributor

Done!

You should be able to use a Custom Presentation Type in the new 0.1.6 release, which should be available via Cocoapods now.

I will update the Readme to provide detailed instructions on how to create a custom presentation, but for now I'll share some example code for creating a 'Top Banner' type alert.

let customPresenter: Presentr = {
        let width = ModalSize.Full // Can still use Presentr's automatically calculated sizes
        let height = ModalSize.Custom(size: 150) // But can use custom ones when needed
        let center = ModalCenterPosition.CustomOrigin(origin: CGPoint(x: 0, y: 0))
        // let center = ModalCenterPosition.Center // Could also use something like this
        // let center = ModalCenterPosition.Custom(centerPoint: CGPoint(x: 50, y: 50)) // or this
        let customType = PresentationType.Custom(width: width, height: height, center: center)

        let customPresenter = Presentr(presentationType: customType)
        customPresenter.transitionType = .CoverVerticalFromTop
        customPresenter.roundCorners = false
        return customPresenter
    }()

@niklassaers
Copy link

Wonderful. :-) Thanks! :-)

@iHunterX
Copy link
Author

Wonderful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants