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

update for swift3 compatible #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 22 additions & 23 deletions Classes/XXPagingScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class XXPagingScrollView: UIView {

private var widthContraint:Constraint? = nil
private var heightContraint:Constraint? = nil

/// 0 means regular paging mode (as long as self)
public var pagingWidth:CGFloat = 0 {
didSet {
Expand All @@ -22,13 +22,13 @@ public class XXPagingScrollView: UIView {
}
else {
widthContraint?.deactivate()
self.scrollView.snp_updateConstraints{ (make) -> Void in
self.scrollView.snp.makeConstraints({ (make) -> Void in
make.width.equalTo(self.pagingWidth)
}
})
}
}
}

/// 0 means regular paging mode (as long as self)
public var pagingHeight:CGFloat = 0 {
didSet {
Expand All @@ -37,49 +37,48 @@ public class XXPagingScrollView: UIView {
}
else {
heightContraint?.deactivate()
self.scrollView.snp_updateConstraints{ (make) -> Void in
self.scrollView.snp.makeConstraints({ (make) -> Void in
make.height.equalTo(self.pagingHeight)
}
})
}
}
}

private class XXReachableScrollView:UIScrollView {
override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool {

override func point(inside: CGPoint, with event: UIEvent?) -> Bool {
return true
}

}

public lazy var scrollView:UIScrollView! = {
var v = XXReachableScrollView()
v.clipsToBounds = false
v.pagingEnabled = true
v.isPagingEnabled = true
v.showsVerticalScrollIndicator = false
v.showsHorizontalScrollIndicator = false
return v
}()

public override init(frame: CGRect) {
super.init(frame: frame)
self.setup()
}

public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.setup()
fatalError("init(coder: ) has not been implemented")
}

private func setup() {

self.addSubview(self.scrollView)
self.scrollView.snp_makeConstraints { (make) -> Void in
self.scrollView.snp.makeConstraints { (make) -> Void in
make.center.equalTo(self)
make.width.equalTo(self.pagingWidth).priorityLow()
make.height.equalTo(self.pagingHeight).priorityLow()
self.widthContraint = make.width.equalTo(self.snp_width).priorityHigh().constraint
self.heightContraint = make.height.equalTo(self.snp_height).priorityHigh().constraint
make.width.equalTo(self.pagingWidth).priority(.low)
make.height.equalTo(self.pagingHeight).priority(.low)
self.widthContraint = make.width.equalTo(self.snp.width).priority(.high).constraint
self.heightContraint = make.height.equalTo(self.snp.height).priority(.high).constraint
}
}

Expand Down