Skip to content

Commit

Permalink
bug fix for custom cell height
Browse files Browse the repository at this point in the history
  • Loading branch information
Suric zhang committed Aug 4, 2017
1 parent 39f4217 commit a61b3db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
16 changes: 5 additions & 11 deletions DropdownMenu/DropUpMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -94,7 +86,6 @@ open class DropUpMenu: UIView {

clipsToBounds = true
setupGestureView()
setupTableView()
}

fileprivate func setupGestureView() {
Expand All @@ -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)])
Expand Down Expand Up @@ -159,6 +150,9 @@ open class DropUpMenu: UIView {
}
isShow = true

setupTableView()
setupBottomSeperatorView()

if let rootView = UIApplication.shared.keyWindow {
windowRootView = rootView
} else {
Expand Down
7 changes: 3 additions & 4 deletions DropdownMenu/DropdownMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -215,6 +211,9 @@ open class DropdownMenu: UIView {

isShow = true

setupTableView()
setupTopSeperatorView()

if let rootView = UIApplication.shared.keyWindow {
windowRootView = rootView
} else {
Expand Down
2 changes: 2 additions & 0 deletions DropdownMenuDemo/DropdownMenuDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ViewController: UIViewController {
}
menuView?.topOffsetY = CGFloat(offSetSlider.value)
menuView?.delegate = self
menuView?.rowHeight = 70
menuView?.showMenu()
}

Expand All @@ -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()
}

Expand Down

0 comments on commit a61b3db

Please sign in to comment.