Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contentView's origin x bug when showOnNav with rightView #11

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added Example/Use Code/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion PageController/MenuItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ class MenuItem: UILabel {
private func setup() {
textAlignment = NSTextAlignment.Center
userInteractionEnabled = true
backgroundColor = UIColor.clearColor()
// backgroundColor = UIColor.clearColor()
backgroundColor = .redColor()
}

override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
Expand Down
3 changes: 3 additions & 0 deletions PageController/MenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ public class MenuView: UIView, MenuItemDelegate {
override public var frame: CGRect {
didSet {
guard contentView != nil else { return }
// FIXME: - reset contentView's x will cause a bug that contentView won't start from x: 0, remove them and works!
// /**
// Make the contentView center, because system will change menuView's frame if it's a titleView.
if (contentView.frame.origin.x + contentView.frame.width / 2) != (bounds.origin.x + bounds.width / 2) {
var contentFrame = contentView.frame
contentFrame.origin.x = bounds.origin.x - (contentFrame.width - bounds.width) / 2
contentView.frame = contentFrame
}
// */
}
}
public var leftView: UIView? {
Expand Down
Binary file added StoryboardExample/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="riQ-5R-hbg">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="riQ-5R-hbg">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
Expand Down Expand Up @@ -82,6 +82,7 @@
<navigationBar key="navigationBar" contentMode="scaleToFill" id="d7C-nr-Dxn">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" red="1" green="0.24210885069999999" blue="1" alpha="1" colorSpace="calibratedRGB"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ class CustomPageController: PageController {
delegate = self
preloadPolicy = PreloadPolicy.Neighbour
menuViewContentMargin = 10
showOnNavigationBar = true
}

override func viewDidLoad() {
super.viewDidLoad()

// Do any additional setup after loading the view.
menuView?.leftView = customButtonWithTitle("Left")
menuView?.rightView = customButtonWithTitle("Right")

// menuView?.leftView = customButtonWithTitle("Left")
menuView?.rightView = customButtonWithTitle("+")
menuView?.backgroundColor = .yellowColor()
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(5.0 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
self.vcTitles = ["Test", "Test", "Test", "Test", "Test", "Test"]
Expand Down