SnowN SnowN - 4 months ago 12
iOS Question

Using KNSemiModalViewController in Swift

I want a TableView in my App like the Maps-App in iOS 10. Im not really sure how i should do this. My idea was to use the Pod of the KNSemiModalViewController (https://github.com/kentnguyen/KNSemiModalViewController).

Take a look at the example show's me that i should only import the Class

import KNSemiModalViewController_hons82


and write this line's? But how should this code look like in Swift?

[self presentSemiViewController:modalVC withOptions:@{
KNSemiModalOptionKeys.pushParentBack : @(NO),
KNSemiModalOptionKeys.parentAlpha : @(0.8)
}];


Or is there a other opportunity to get a view like the iOS 10 Maps-App?

Answer

Ok, it's really simple.

import KNSemiModalViewController_hons82

After the Import you just need the following lines of code to open the view called by button click, for example.

let modalView = UIStoryboard(name: "SemiModalView", bundle:
    nil).instantiateViewControllerWithIdentifier("SemiModalView")

self.presentSemiViewController(modalView, withOptions:
    [KNSemiModalOptionKeys.pushParentBack.takeRetainedValue():false, 
     KNSemiModalOptionKeys.parentAlpha.takeRetainedValue():0.5, 
     KNSemiModalOptionKeys.animationDuration.takeRetainedValue():0.3])

In the called VC you can use

self.view.frame = CGRectMake(0, 0, self.view.frame.width, (self.view.frame.height * 0.5))

in the viewDidLoad() Methode to set the size of the SemiModalView.
You can also add a button or something else to dismiss the SemiModalView with the following line. self.dismissSemiModalView()

Comments