evnaz / ENSwiftSideMenu

A simple side menu for iOS written in Swift.
MIT License
1.82k stars 281 forks source link

How to bring custom view in front of SideMenu ?? #132

Open intellignt-idiot opened 8 years ago

intellignt-idiot commented 8 years ago

I am using UIView as header and navigation bar is hidden. Now side menu overlaps the headerView. How to bring my headerView in front or above the side menu ?

I already tried with navigationControllerInstance.bringSubViewToFront(headerView), but it did not work.

Thanks

adgrace commented 8 years ago

I have tried to add view.bringSubviewToFront(UIView) to the sideMenuDidOpen() function but it did not work. Any ideas's anyone?

intellignt-idiot commented 8 years ago

@alexgrace95 Did you manage to find any workaround for this issue ??

jas1003 commented 8 years ago

Hi @intellignt-idiot there is a very simple Work around for the same your header view would come above the Side Menu

In Class ENSideMenu.swift

Function : func updateFrame() { var width:CGFloat var height:CGFloat (width, height) = adjustFrameDimensions( sourceView.frame.size.width, height: sourceView.frame.size.height) let menuFrame = CGRectMake( (menuPosition == .Left) ? isMenuOpen ? 0 : -menuWidth-1.0 : isMenuOpen ? width - menuWidth : width+1.0, sourceView.frame.origin.y, menuWidth, height ) sideMenuContainerView.frame = menuFrame }

Just add the height of your headerView to sourceView.frame.origin.y

Hope This answers your query

intellignt-idiot commented 8 years ago

Hello @jas1003 thanks for your help. But your workaround din't work. I can see the frame with correct y position but still it keeps at 0 origin.

During the first time of opening the menu, it starts from the y axis that I added in sourceView.frame.origin.y, but it animates to 0 automatically and does not stay at the desired y position.

I replaced the line sourceView.frame.origin.y by 62(height of my header), but like I said, it did not stay there. It always starts from 0 origin. Did I miss anything from your comment ?