Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ build/
xcuserdata
data/

Pods/
Pods/

docs/1.2
7 changes: 4 additions & 3 deletions Example/PinLayoutSample/UI/Common/BasicView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ class BasicView: UIView {
override func layoutSubviews() {
super.layoutSubviews()

label.pin.top().left().right().margin(4).fitSize()
label.pin.top().left().right().margin(4).sizeToFit(.width)
}

var sizeThatFitsExpectedArea: CGFloat = 40 * 40
var sizeThatFitSizeOffset: CGFloat = 0

override func sizeThatFits(_ size: CGSize) -> CGSize {
var newSize = CGSize()
if size.width != CGFloat.greatestFiniteMagnitude {
newSize.width = size.width
newSize.width = size.width + sizeThatFitSizeOffset
newSize.height = sizeThatFitsExpectedArea / newSize.width
} else if size.height != CGFloat.greatestFiniteMagnitude {
newSize.height = size.height
newSize.height = size.height + sizeThatFitSizeOffset
newSize.width = sizeThatFitsExpectedArea / newSize.height
} else {
newSize.width = 40
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ import PinLayout
class AdjustToContainerView: BaseView {
fileprivate let contentView = UIView()
fileprivate let languageSelectorView = ChoiceSelectorView(text: "What is your favorite language?", choices: ["Swift", "Objective-C", "C++"])
fileprivate let swiftOpinionSelectorView = ChoiceSelectorView(text: "Overall, are you satisfied with the Swift performance in your projects?", choices: ["Yes", "No"])
fileprivate let swiftUsageSelectorView = ChoiceSelectorView(text: "How often do you typically use Swift?", choices: ["Daily", "Weekly", "Montly", "Do not use"])
fileprivate let swiftOpinionSelector = ChoiceSelectorView(text: "Overall, are you satisfied with the Swift performance in your projects?", choices: ["Yes", "No"])
fileprivate let swiftUsageSelector = ChoiceSelectorView(text: "How often do you typically use Swift?", choices: ["Daily", "Weekly", "Montly", "Do not use"])

override init() {
super.init()

addSubview(contentView)

contentView.addSubview(languageSelectorView)
contentView.addSubview(swiftOpinionSelectorView)
contentView.addSubview(swiftUsageSelectorView)
contentView.addSubview(swiftOpinionSelector)
contentView.addSubview(swiftUsageSelector)
}

required init?(coder aDecoder: NSCoder) {
Expand All @@ -46,8 +46,8 @@ class AdjustToContainerView: BaseView {
// Layout the contentView using the view's safeArea.
contentView.pin.all().margin(safeArea)

languageSelectorView.pin.top().left().right().fitSize()
swiftOpinionSelectorView.pin.below(of: languageSelectorView, aligned: .left).right().marginTop(10).fitSize()
swiftUsageSelectorView.pin.below(of: swiftOpinionSelectorView, aligned: .left).right().marginTop(10).fitSize()
languageSelectorView.pin.top().left().right().sizeToFit(.width)
swiftOpinionSelector.pin.below(of: languageSelectorView, aligned: .left).right().marginTop(10).sizeToFit(.width)
swiftUsageSelector.pin.below(of: swiftOpinionSelector, aligned: .left).right().marginTop(10).sizeToFit(.width)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ class ChoiceSelectorView: UIView {
if frame.width > 500 {
// The UISegmentedControl is at the top-right corner and the label takes the remaining horizontal space.
segmentedControl.pin.top().right().margin(margin)
textLabel.pin.top().left().before(of: segmentedControl).margin(margin).fitSize()
textLabel.pin.top().left().before(of: segmentedControl).margin(margin).sizeToFit(.width)
} else {
// The UISegmentedControl is placed below the label.
textLabel.pin.top().left().right().margin(margin).fitSize()
textLabel.pin.top().left().right().margin(margin).sizeToFit(.width)
segmentedControl.pin.below(of: textLabel).right().margin(margin)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class HouseCell: UICollectionViewCell {
nameLabel.text = house.name
priceLabel.text = house.price
distanceLabel.text = "\(house.distance) KM"
distanceLabel.textAlignment = .right

mainImage.download(url: house.mainImageURL)
mainImage.contentMode = .scaleAspectFill
Expand All @@ -79,13 +80,13 @@ class HouseCell: UICollectionViewCell {

private func layout() {
headerView.pin.top().horizontally().height(100)
nameLabel.pin.top().horizontally().margin(padding).fitSize()
nameLabel.pin.top().horizontally().margin(padding).sizeToFit(.width)

mainImage.pin.below(of: nameLabel).horizontally().height(300).marginTop(padding)

footerView.pin.below(of: mainImage).horizontally()
priceLabel.pin.top().horizontally().fitSize().margin(6, padding)
distanceLabel.pin.top().after(of: priceLabel).right().fitSize().justify(.right).margin(6, padding)
priceLabel.pin.top().horizontally().margin(6, padding).sizeToFit(.width)
distanceLabel.pin.top().after(of: priceLabel).right().margin(6, padding).sizeToFit(.width)
footerView.pin.height(max(priceLabel.frame.maxY, distanceLabel.frame.maxY) + 6)

contentView.pin.height(footerView.frame.maxY)
Expand Down
2 changes: 1 addition & 1 deletion Example/PinLayoutSample/UI/Examples/Intro/IntroView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class IntroView: BaseView {

logo.pin.top().left().size(100).aspectRatio().marginTop(10)
segmented.pin.after(of: logo, aligned: .top).right().marginLeft(10)
textLabel.pin.below(of: segmented, aligned: .left).width(of: segmented).pinEdges().marginTop(10).fitSize()
textLabel.pin.below(of: segmented, aligned: .left).width(of: segmented).pinEdges().marginTop(10).sizeToFit(.width)
separatorView.pin.below(of: [logo, textLabel], aligned: .left).right(to: segmented.edge.right).marginTop(10)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ - (void) layoutSubviews {

[[[[[[logo.pinObjc top] left] width:100] aspectRatio] marginWithTop:topLayoutGuide + 10 horizontal:10 bottom:10] layout];
[[[[segmented.pinObjc rightOf:logo aligned:VerticalAlignTop] right] marginHorizontal:10] layout];
[[[[[[textLabel.pinObjc belowOf:segmented aligned:HorizontalAlignLeft] widthOf:segmented] pinEdges] marginTop:10] fitSize] layout];
[[[[[[textLabel.pinObjc belowOf:segmented aligned:HorizontalAlignLeft] widthOf:segmented] pinEdges] marginTop:10] sizeToFit:FitWidth] layout];
[[[[[separatorView.pinObjc belowOfViews:@[logo, textLabel] aligned:HorizontalAlignLeft] rightTo:segmented.edge.right] height:1] marginTop:10] layout];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class IntroRTLView: BaseView {

logo.pin.top().start().size(100).aspectRatio().marginTop(10)
segmented.pin.after(of: logo, aligned: .top).end().marginStart(10)
textLabel.pin.below(of: segmented, aligned: .start).width(of: segmented).pinEdges().marginTop(10).fitSize()
textLabel.pin.below(of: segmented, aligned: .start).width(of: segmented).pinEdges().marginTop(10).sizeToFit(.width)
separatorView.pin.below(of: [logo, textLabel], aligned: .start).end(to: segmented.edge.end).marginTop(10)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class MethodCell: UITableViewCell {

fileprivate func layout() {
iconImageView.pin.top().left().size(30).margin(margin)
nameLabel.pin.right(of: iconImageView, aligned: .center).right().marginHorizontal(margin).fitSize()
descriptionLabel.pin.below(of: [iconImageView, nameLabel]).left().right().margin(margin).fitSize()
nameLabel.pin.right(of: iconImageView, aligned: .center).right().marginHorizontal(margin).sizeToFit(.width)
descriptionLabel.pin.below(of: [iconImageView, nameLabel]).left().right().margin(margin).sizeToFit(.width)
}

override func sizeThatFits(_ size: CGSize) -> CGSize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ class MethodGroupHeader: UITableViewHeaderFooterView {
override func layoutSubviews() {
super.layoutSubviews()

titleLabel.pin.left().right().vCenter().margin(10).fitSize()
titleLabel.pin.left().right().vCenter().margin(10).sizeToFit(.width)
}
}
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
gem 'synx'
gem 'cocoapods'
gem 'jazzy'
gem 'fastlane'
gem 'jazzy', '0.9'
gem 'fastlane'
33 changes: 19 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ GEM
faraday_middleware (0.12.2)
faraday (>= 0.7.4, < 1.0)
fastimage (2.1.0)
fastlane (2.62.1)
fastlane (2.63.0)
CFPropertyList (>= 2.3, < 3.0.0)
addressable (>= 2.3, < 3.0.0)
babosa (>= 1.0.2, < 2.0.0)
Expand Down Expand Up @@ -124,14 +124,18 @@ GEM
httpclient (2.8.3)
i18n (0.9.0)
concurrent-ruby (~> 1.0)
jazzy (0.0.14)
activesupport (~> 4.1)
jazzy (0.9.0)
cocoapods (~> 1.0)
mustache (~> 0.99)
nokogiri (~> 1.6)
open4
redcarpet (~> 3.2)
rouge (~> 1.5)
sass (~> 3.4)
sqlite3 (~> 1.3)
xcinvoke (~> 0.3.0)
json (2.1.0)
jwt (2.1.0)
liferaft (0.0.6)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
Expand All @@ -141,7 +145,6 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mini_magick (4.5.1)
mini_portile2 (2.3.0)
minitest (5.10.3)
molinillo (0.5.7)
multi_json (1.12.2)
Expand All @@ -151,8 +154,7 @@ GEM
nanaimo (0.2.3)
nap (1.1.0)
netrc (0.11.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
open4 (1.3.4)
os (0.9.6)
plist (3.3.0)
public_suffix (2.0.5)
Expand All @@ -165,10 +167,10 @@ GEM
declarative-option (< 0.2.0)
uber (< 0.2.0)
retriable (3.1.1)
rouge (2.0.7)
rouge (1.11.1)
ruby-macho (1.1.0)
rubyzip (1.2.1)
sass (3.5.2)
sass (3.5.3)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -180,6 +182,7 @@ GEM
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
slack-notifier (1.5.1)
sqlite3 (1.3.13)
synx (0.2.1)
clamp (~> 0.6)
colorize (~> 0.7)
Expand All @@ -188,22 +191,24 @@ GEM
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
tty-screen (0.5.0)
tzinfo (1.2.3)
tty-screen (0.5.1)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uber (0.1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)
unicode-display_width (1.3.0)
word_wrap (1.0.0)
xcinvoke (0.3.0)
liferaft (~> 0.0.6)
xcodeproj (1.5.3)
CFPropertyList (~> 2.3.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.3)
xcpretty (0.2.8)
rouge (~> 2.0.7)
xcpretty (0.2.6)
rouge (~> 1.8)
xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7)

Expand All @@ -213,7 +218,7 @@ PLATFORMS
DEPENDENCIES
cocoapods
fastlane
jazzy
jazzy (= 0.9)
synx

BUNDLED WITH
Expand Down
2 changes: 1 addition & 1 deletion PinLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = "PinLayout"
s.version = "1.4.2"
s.version = "1.5.0"
s.summary = "Fast Swift UIViews layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable."
s.description = "Fast Swift UIViews layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable."

Expand Down
4 changes: 0 additions & 4 deletions PinLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 242E8DC11EED5982005935FB /* RelativePositionMultipleViewsSpec.swift */; };
244C6E151E776A0C0074FC74 /* MarginsSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 244C6E141E776A0C0074FC74 /* MarginsSpec.swift */; };
244DF3061EF46FC20090508B /* PinLayoutTVOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 244DF3041EF46FB90090508B /* PinLayoutTVOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
245302071ED05FD000E13F29 /* AccurencyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 245302061ED05FD000E13F29 /* AccurencyTests.swift */; };
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */; };
2469C5001E75D74000073BEE /* AdjustSizeSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C4FF1E75D74000073BEE /* AdjustSizeSpec.swift */; };
2469C5021E75D88500073BEE /* BasicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2469C5011E75D88500073BEE /* BasicView.swift */; };
Expand Down Expand Up @@ -89,7 +88,6 @@
244DF2F81EF46C500090508B /* PinLayoutTVOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PinLayoutTVOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
244DF3011EF46F670090508B /* InfoTVOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = InfoTVOS.plist; path = Sources/InfoTVOS.plist; sourceTree = SOURCE_ROOT; };
244DF3041EF46FB90090508B /* PinLayoutTVOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PinLayoutTVOS.h; path = Sources/PinLayoutTVOS.h; sourceTree = SOURCE_ROOT; };
245302061ED05FD000E13F29 /* AccurencyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccurencyTests.swift; sourceTree = "<group>"; };
2469C4FB1E74855D00073BEE /* PinEdgeCoordinateSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PinEdgeCoordinateSpec.swift; sourceTree = "<group>"; };
2469C4FF1E75D74000073BEE /* AdjustSizeSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AdjustSizeSpec.swift; sourceTree = "<group>"; };
2469C5011E75D88500073BEE /* BasicView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -206,7 +204,6 @@
children = (
249EFE8A1E64FB4C00165E39 /* Info.plist */,
2469C5011E75D88500073BEE /* BasicView.swift */,
245302061ED05FD000E13F29 /* AccurencyTests.swift */,
2469C4FF1E75D74000073BEE /* AdjustSizeSpec.swift */,
248E4C721F7A83FA00C0E7F7 /* AspectRatioTests.swift */,
240F88BC1F0C042500280FC8 /* JustifyAlignSpec.swift */,
Expand Down Expand Up @@ -514,7 +511,6 @@
242E8DC31EED5AB2005935FB /* RelativePositionMultipleViewsSpec.swift in Sources */,
2469C5041E75DB7600073BEE /* RectNimbleMatcher.swift in Sources */,
242723731F008BF7006A5C3A /* MinMaxWidthHeightSpec.swift in Sources */,
245302071ED05FD000E13F29 /* AccurencyTests.swift in Sources */,
2469C4FC1E74855D00073BEE /* PinEdgeCoordinateSpec.swift in Sources */,
24D18D171F3B4381008129EF /* RTLSpec.swift in Sources */,
2469C5021E75D88500073BEE /* BasicView.swift in Sources */,
Expand Down
Loading