diff --git a/DropdownMenu/DropUpMenu.swift b/DropdownMenu/DropUpMenu.swift index db3d4b3..d470c3e 100644 --- a/DropdownMenu/DropUpMenu.swift +++ b/DropdownMenu/DropUpMenu.swift @@ -6,14 +6,6 @@ // Copyright © 2016年 teambition. All rights reserved. // -// -// DropUpMenu.swift -// DropUpMenu -// -// Created by Suric on 16/5/26. -// Copyright © 2016年 teambition. All rights reserved. -// - import UIKit public protocol DropUpMenuDelegate: class { @@ -94,7 +86,6 @@ open class DropUpMenu: UIView { clipsToBounds = true setupGestureView() - setupTableView() } fileprivate func setupGestureView() { @@ -110,12 +101,12 @@ open class DropUpMenu: UIView { gestureView.addGestureRecognizer(tapGestureRecognizer) } - fileprivate func setupTopSeperatorView() { + fileprivate func setupBottomSeperatorView() { let seperatorView = UIView() seperatorView.backgroundColor = tableViewSeperatorColor addSubview(seperatorView) seperatorView.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([NSLayoutConstraint.init(item: seperatorView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0)]) + NSLayoutConstraint.activate([NSLayoutConstraint.init(item: seperatorView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0)]) NSLayoutConstraint.activate([NSLayoutConstraint.init(item: seperatorView, attribute: .left, relatedBy: .equal, toItem: self, attribute: .left, multiplier: 1.0, constant: 0)]) NSLayoutConstraint.activate([NSLayoutConstraint.init(item: seperatorView, attribute: .right, relatedBy: .equal, toItem: self, attribute: .right, multiplier: 1.0, constant: 0)]) NSLayoutConstraint.activate([NSLayoutConstraint.init(item: seperatorView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1.0, constant: 0.5)]) @@ -159,6 +150,9 @@ open class DropUpMenu: UIView { } isShow = true + setupTableView() + setupBottomSeperatorView() + if let rootView = UIApplication.shared.keyWindow { windowRootView = rootView } else { diff --git a/DropdownMenu/DropdownMenu.swift b/DropdownMenu/DropdownMenu.swift index 6801945..1e74b7c 100644 --- a/DropdownMenu/DropdownMenu.swift +++ b/DropdownMenu/DropdownMenu.swift @@ -90,8 +90,6 @@ open class DropdownMenu: UIView { clipsToBounds = true setupGestureView() - setupTableView() - setupTopSeperatorView() NotificationCenter.default.addObserver(self, selector: #selector(self.updateForOrientationChange(_:)), name: NSNotification.Name.UIApplicationWillChangeStatusBarOrientation, object: nil) } @@ -106,8 +104,6 @@ open class DropdownMenu: UIView { clipsToBounds = true setupGestureView() - setupTableView() - setupTopSeperatorView() NotificationCenter.default.addObserver(self, selector: #selector(self.updateForOrientationChange(_:)), name: NSNotification.Name.UIApplicationWillChangeStatusBarOrientation, object: nil) } @@ -215,6 +211,9 @@ open class DropdownMenu: UIView { isShow = true + setupTableView() + setupTopSeperatorView() + if let rootView = UIApplication.shared.keyWindow { windowRootView = rootView } else { diff --git a/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift b/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift index 4dfa4b9..4dda3fa 100644 --- a/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift +++ b/DropdownMenuDemo/DropdownMenuDemo/ViewController.swift @@ -52,6 +52,7 @@ class ViewController: UIViewController { } menuView?.topOffsetY = CGFloat(offSetSlider.value) menuView?.delegate = self + menuView?.rowHeight = 70 menuView?.showMenu() } @@ -65,6 +66,7 @@ class ViewController: UIViewController { items = [data] let menuView = DropUpMenu(items: data, selectedRow: 0, bottomOffsetY: self.tabBarController?.tabBar.frame.height ?? 0) menuView.delegate = self + menuView.rowHeight = 70 menuView.showMenu() }