How to reference the default UIView to animate in Swift?












-1














I have 2 view controllers: "MapScreenVC" and "PullUpMenuVC"; When you tap a button on the "MapScreenVC", the "PullUpMenuVC" should appear, pulling up from the bottom. Them problem I am having is that in regards to the default UIView for the "PullUpMenuVC", any visual changes I make in storyboards do not show up.



That said, when I call my prepareBackgroundView() function, the view changes accordingly upon build.



How can I edit the view in storyboards but still animate the view in code? I feel like I have a misunderstanding of how views are referenced from the storyboard. Is the view that I am animating not the default view of the view controller, which is the same view that should be visually edited in the storyboard?



My "PullUpMenuVC" class:



override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareBackgroundView()
}

func prepareBackgroundView()
{
view.backgroundColor = .white
view.tintColor = defaultTint
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animate(withDuration: 0.35) { [weak self] in
let frame = self?.view.frame
let yComponent = UIScreen.main.bounds.height * 1
self?.view.frame = CGRect(0, yComponent, frame!.width, frame!.height)
}


This is a screenshot of my storyboard:
screenshot of stotyboard



I should also point out that I have connected the "PullUpMenuVC" class to the view controller in my storyboard.










share|improve this question
























  • Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
    – J. Doe
    Nov 19 '18 at 15:54
















-1














I have 2 view controllers: "MapScreenVC" and "PullUpMenuVC"; When you tap a button on the "MapScreenVC", the "PullUpMenuVC" should appear, pulling up from the bottom. Them problem I am having is that in regards to the default UIView for the "PullUpMenuVC", any visual changes I make in storyboards do not show up.



That said, when I call my prepareBackgroundView() function, the view changes accordingly upon build.



How can I edit the view in storyboards but still animate the view in code? I feel like I have a misunderstanding of how views are referenced from the storyboard. Is the view that I am animating not the default view of the view controller, which is the same view that should be visually edited in the storyboard?



My "PullUpMenuVC" class:



override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareBackgroundView()
}

func prepareBackgroundView()
{
view.backgroundColor = .white
view.tintColor = defaultTint
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animate(withDuration: 0.35) { [weak self] in
let frame = self?.view.frame
let yComponent = UIScreen.main.bounds.height * 1
self?.view.frame = CGRect(0, yComponent, frame!.width, frame!.height)
}


This is a screenshot of my storyboard:
screenshot of stotyboard



I should also point out that I have connected the "PullUpMenuVC" class to the view controller in my storyboard.










share|improve this question
























  • Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
    – J. Doe
    Nov 19 '18 at 15:54














-1












-1








-1







I have 2 view controllers: "MapScreenVC" and "PullUpMenuVC"; When you tap a button on the "MapScreenVC", the "PullUpMenuVC" should appear, pulling up from the bottom. Them problem I am having is that in regards to the default UIView for the "PullUpMenuVC", any visual changes I make in storyboards do not show up.



That said, when I call my prepareBackgroundView() function, the view changes accordingly upon build.



How can I edit the view in storyboards but still animate the view in code? I feel like I have a misunderstanding of how views are referenced from the storyboard. Is the view that I am animating not the default view of the view controller, which is the same view that should be visually edited in the storyboard?



My "PullUpMenuVC" class:



override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareBackgroundView()
}

func prepareBackgroundView()
{
view.backgroundColor = .white
view.tintColor = defaultTint
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animate(withDuration: 0.35) { [weak self] in
let frame = self?.view.frame
let yComponent = UIScreen.main.bounds.height * 1
self?.view.frame = CGRect(0, yComponent, frame!.width, frame!.height)
}


This is a screenshot of my storyboard:
screenshot of stotyboard



I should also point out that I have connected the "PullUpMenuVC" class to the view controller in my storyboard.










share|improve this question















I have 2 view controllers: "MapScreenVC" and "PullUpMenuVC"; When you tap a button on the "MapScreenVC", the "PullUpMenuVC" should appear, pulling up from the bottom. Them problem I am having is that in regards to the default UIView for the "PullUpMenuVC", any visual changes I make in storyboards do not show up.



That said, when I call my prepareBackgroundView() function, the view changes accordingly upon build.



How can I edit the view in storyboards but still animate the view in code? I feel like I have a misunderstanding of how views are referenced from the storyboard. Is the view that I am animating not the default view of the view controller, which is the same view that should be visually edited in the storyboard?



My "PullUpMenuVC" class:



override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
prepareBackgroundView()
}

func prepareBackgroundView()
{
view.backgroundColor = .white
view.tintColor = defaultTint
}

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)

UIView.animate(withDuration: 0.35) { [weak self] in
let frame = self?.view.frame
let yComponent = UIScreen.main.bounds.height * 1
self?.view.frame = CGRect(0, yComponent, frame!.width, frame!.height)
}


This is a screenshot of my storyboard:
screenshot of stotyboard



I should also point out that I have connected the "PullUpMenuVC" class to the view controller in my storyboard.







ios swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 18:49









Tobias Wilfert

7152820




7152820










asked Nov 19 '18 at 15:50









dodthan

1




1












  • Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
    – J. Doe
    Nov 19 '18 at 15:54


















  • Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
    – J. Doe
    Nov 19 '18 at 15:54
















Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
– J. Doe
Nov 19 '18 at 15:54




Offtopic: Notice that 1. the [weak self] block isn't needed and 2. If for some reason self is nil, the system will crash because you force unwrap frame.height/width.
– J. Doe
Nov 19 '18 at 15:54












1 Answer
1






active

oldest

votes


















1














I think you have misunderstood how this is usually done in iOS and Xcode. From your description above I understand you want to do something that looks like a Modal View Presentation.



If you use the default modal view presentation iOS offers for doing that transition between ViewController, you will not have to implement the animations yourself. In fact you can do the whole think in the Storyboard by just hooking up the segues.



I am attaching some reading material that might help you.
https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html



https://www.raywenderlich.com/462-storyboards-tutorial-for-ios-part-2



Custom transition if you need it.
https://www.raywenderlich.com/359-ios-animation-tutorial-custom-view-controller-presentation-transitions



Hope the above help.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378247%2fhow-to-reference-the-default-uiview-to-animate-in-swift%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    I think you have misunderstood how this is usually done in iOS and Xcode. From your description above I understand you want to do something that looks like a Modal View Presentation.



    If you use the default modal view presentation iOS offers for doing that transition between ViewController, you will not have to implement the animations yourself. In fact you can do the whole think in the Storyboard by just hooking up the segues.



    I am attaching some reading material that might help you.
    https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html



    https://www.raywenderlich.com/462-storyboards-tutorial-for-ios-part-2



    Custom transition if you need it.
    https://www.raywenderlich.com/359-ios-animation-tutorial-custom-view-controller-presentation-transitions



    Hope the above help.






    share|improve this answer


























      1














      I think you have misunderstood how this is usually done in iOS and Xcode. From your description above I understand you want to do something that looks like a Modal View Presentation.



      If you use the default modal view presentation iOS offers for doing that transition between ViewController, you will not have to implement the animations yourself. In fact you can do the whole think in the Storyboard by just hooking up the segues.



      I am attaching some reading material that might help you.
      https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html



      https://www.raywenderlich.com/462-storyboards-tutorial-for-ios-part-2



      Custom transition if you need it.
      https://www.raywenderlich.com/359-ios-animation-tutorial-custom-view-controller-presentation-transitions



      Hope the above help.






      share|improve this answer
























        1












        1








        1






        I think you have misunderstood how this is usually done in iOS and Xcode. From your description above I understand you want to do something that looks like a Modal View Presentation.



        If you use the default modal view presentation iOS offers for doing that transition between ViewController, you will not have to implement the animations yourself. In fact you can do the whole think in the Storyboard by just hooking up the segues.



        I am attaching some reading material that might help you.
        https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html



        https://www.raywenderlich.com/462-storyboards-tutorial-for-ios-part-2



        Custom transition if you need it.
        https://www.raywenderlich.com/359-ios-animation-tutorial-custom-view-controller-presentation-transitions



        Hope the above help.






        share|improve this answer












        I think you have misunderstood how this is usually done in iOS and Xcode. From your description above I understand you want to do something that looks like a Modal View Presentation.



        If you use the default modal view presentation iOS offers for doing that transition between ViewController, you will not have to implement the animations yourself. In fact you can do the whole think in the Storyboard by just hooking up the segues.



        I am attaching some reading material that might help you.
        https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/PresentingaViewController.html



        https://www.raywenderlich.com/462-storyboards-tutorial-for-ios-part-2



        Custom transition if you need it.
        https://www.raywenderlich.com/359-ios-animation-tutorial-custom-view-controller-presentation-transitions



        Hope the above help.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 16:48









        George Bafaloukas

        67247




        67247






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53378247%2fhow-to-reference-the-default-uiview-to-animate-in-swift%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules