WMPageController-Swift
WMPageController-Swift copied to clipboard
contentView's origin x bug when showOnNav with rightView
hi wangmchn, I don't know whether it's a bug that contentView's origin not starts with x:0 when I set showOnNav with a rightView. So I make a PR with some color to mark their frames, just like 
In my solution:
public class MenuView: UIView, MenuItemDelegate {
// MARK: - Public vars
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
}
*/
}
}
I know that adding those codes' reason, but contentView still center its frame after I remove those codes, I wonder whether some code has fixed it. My PR project will show the bug, you can check it out and remove those codes to test it. Thanks.
Hey,sorry for the bug and carthage problem. Cause I have some works to do with my thesis(it's important),I will check it later.
Sorry again.
发自我的 iPhone
在 2016年5月24日,11:38,litt1e-p [email protected] 写道:
hi wangmchn, I don't know whether it's a bug that contentView's origin not starts with x:0 when I set showOnNav with a rightView. So I make a PR with some color to mark their frames, just like
In my solution:
public class MenuView: UIView, MenuItemDelegate {
// MARK: - Public vars 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 } */ } } I know that adding those codes' reason, but contentView still center its frame after I remove those codes, I wonder whether some code has fixed it. My PR project will show the bug, you can check it out and remove those codes to test it. Thanks.
You can view, comment on, or merge this pull request online at:
https://github.com/wangmchn/WMPageController-Swift/pull/11
Commit Summary
menuView
s frame origin.x bugfix control menuView as subView of navigationBar menuViews frame origin.x bugfix control menuView as subView of navigationBar hows the origin bug when setting the rightView in NavBar Merge branch 'master' of https://github.com/litt1e-p/WMPageController-Swift hows the origin bug when setting the rightView in NavBar File ChangesA .DS_Store (0) A Example/Use Code/.DS_Store (0) M PageController/MenuItem.swift (3) M PageController/MenuView.swift (3) A StoryboardExample/.DS_Store (0) M StoryboardExample/StoryboardExample/Base.lproj/Main.storyboard (3) M StoryboardExample/StoryboardExample/ParentController/CustomPageController.swift (7) Patch Links:
https://github.com/wangmchn/WMPageController-Swift/pull/11.patch https://github.com/wangmchn/WMPageController-Swift/pull/11.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub
all right. waiting for you!
2016年5月24日星期二,Wang Ming [email protected] 写道:
Hey,sorry for the bug and carthage problem. Cause I have some works to do with my thesis(it's important),I will check it later.
Sorry again.
发自我的 iPhone
在 2016年5月24日,11:38,litt1e-p <[email protected] javascript:_e(%7B%7D,'cvml','[email protected]');> 写道:
hi wangmchn, I don't know whether it's a bug that contentView's origin not starts with x:0 when I set showOnNav with a rightView. So I make a PR with some color to mark their frames, just like
In my solution:
public class MenuView: UIView, MenuItemDelegate {
// MARK: - Public vars 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 } */ } } I know that adding those codes' reason, but contentView still center its frame after I remove those codes, I wonder whether some code has fixed it. My PR project will show the bug, you can check it out and remove those codes to test it. Thanks.
You can view, comment on, or merge this pull request online at:
https://github.com/wangmchn/WMPageController-Swift/pull/11
Commit Summary
menuView
s frame origin.x bugfix control menuView as subView of navigationBar menuViews frame origin.x bugfix control menuView as subView of navigationBar hows the origin bug when setting the rightView in NavBar Merge branch 'master' of https://github.com/litt1e-p/WMPageController-Swift hows the origin bug when setting the rightView in NavBar File ChangesA .DS_Store (0) A Example/Use Code/.DS_Store (0) M PageController/MenuItem.swift (3) M PageController/MenuView.swift (3) A StoryboardExample/.DS_Store (0) M StoryboardExample/StoryboardExample/Base.lproj/Main.storyboard (3) M StoryboardExample/StoryboardExample/ParentController/CustomPageController.swift (7) Patch Links:
https://github.com/wangmchn/WMPageController-Swift/pull/11.patch https://github.com/wangmchn/WMPageController-Swift/pull/11.diff — You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/wangmchn/WMPageController-Swift/pull/11#issuecomment-221170380
Hey, @litt1e-p I have checked the pr, and it's a bug. I fixed as the follow:
// MARK: - Public vars
override public var frame: CGRect {
didSet {
guard contentView != nil else { return }
// Take rightView / leftView and contentMargin into consideration
let rightMargin = (rightView == nil) ? contentMargin : contentMargin + rightView!.frame.width
let leftMargin = (leftView == nil) ? contentMargin : contentMargin + leftView!.frame.width
let contentWidth = CGRectGetWidth(contentView.frame) + leftMargin + rightMargin
let startX = (leftView != nil) ? leftView!.frame.origin.x : (contentView.frame.origin.x - contentMargin)
// Make the contentView center, because system will change menuView's frame if it's a titleView.
if (startX + contentWidth / 2 != bounds.width / 2) {
let xOffset = (contentWidth - bounds.width) / 2
contentView.frame.origin.x -= xOffset
rightView?.frame.origin.x -= xOffset
leftView?.frame.origin.x -= xOffset
}
}
}
You can see https://github.com/wangmchn/WMPageController-Swift/commit/a05b50c6de09da3b9eb1d9051b2ab20e122c9937 for more information.
I am glad about you fixed the bug, but I can't pod search for ver 1.3.6?
Ouch,I forgot pushing it to pod. Try it now.