Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/2.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Ermolenko committed Nov 30, 2017
2 parents 1882918 + 445a024 commit 6d55b3a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Framezilla.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Framezilla"
spec.version = "2.4.0"
spec.version = "2.4.1"
spec.summary = "Comfortable syntax for working with frames."

spec.homepage = "https://github.com/Otbivnoe/Framezilla"
Expand Down
20 changes: 16 additions & 4 deletions Sources/Maker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,15 @@ public final class Maker {

@discardableResult public func centerY(between relationView1: RelationView<VerticalRelation>,
_ relationView2: RelationView<VerticalRelation>) -> Maker {
let view1 = relationView1.view
let view2 = relationView2.view

let relationType1 = relationView1.relationType
let relationType2 = relationView2.relationType

let handler = { [unowned self] in
let y1 = self.convertedValue(for: relationView1.relationType, with: relationView1.view)
let y2 = self.convertedValue(for: relationView2.relationType, with: relationView2.view)
let y1 = self.convertedValue(for: relationType1, with: view1)
let y2 = self.convertedValue(for: relationType2, with: view2)

let topY = y1 < y2 ? y1 : y2
let bottomY = y1 >= y2 ? y1 : y2
Expand Down Expand Up @@ -778,9 +784,15 @@ public final class Maker {

@discardableResult public func centerX(between relationView1: RelationView<HorizontalRelation>,
_ relationView2: RelationView<HorizontalRelation>) -> Maker {
let view1 = relationView1.view
let view2 = relationView2.view

let relationType1 = relationView1.relationType
let relationType2 = relationView2.relationType

let handler = { [unowned self] in
let x1 = self.convertedValue(for: relationView1.relationType, with: relationView1.view)
let x2 = self.convertedValue(for: relationView2.relationType, with: relationView2.view)
let x1 = self.convertedValue(for: relationType1, with: view1)
let x2 = self.convertedValue(for: relationType2, with: view2)

let rightX = x1 < x2 ? x1 : x2
let leftX = x1 >= x2 ? x1 : x2
Expand Down
34 changes: 17 additions & 17 deletions Sources/MakerHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ extension Maker {
}

switch type {
case .top: return convertedRect.minY
case .bottom: return convertedRect.maxY
case .centerY: return view.contains(self.view) ? convertedRect.height / 2 : convertedRect.midY
case .centerX: return view.contains(self.view) ? convertedRect.width / 2 : convertedRect.midX
case .right: return convertedRect.maxX
case .left: return convertedRect.minX
default: return 0
case .top: return convertedRect.minY
case .bottom: return convertedRect.maxY
case .centerY: return view.contains(self.view) ? convertedRect.height / 2 : convertedRect.midY
case .centerX: return view.contains(self.view) ? convertedRect.width / 2 : convertedRect.midX
case .right: return convertedRect.maxX
case .left: return convertedRect.minX
default: return 0
}
}

func relationSize(view: UIView, for type: RelationType) -> CGFloat {
switch type {
case .width: return view.bounds.width
case .height: return view.bounds.height
default: return 0
case .width: return view.bounds.width
case .height: return view.bounds.height
default: return 0
}
}
}
Expand All @@ -69,13 +69,13 @@ extension CGRect {
mutating func setValue(_ value: CGFloat, for type: RelationType) {
var frame = self
switch type {
case .width: frame.size.width = value
case .height: frame.size.height = value
case .left: frame.origin.x = value
case .top: frame.origin.y = value
case .centerX: frame.origin.x = value - width/2
case .centerY: frame.origin.y = value - height/2
default: break
case .width: frame.size.width = value
case .height: frame.size.height = value
case .left: frame.origin.x = value
case .top: frame.origin.y = value
case .centerX: frame.origin.x = value - width/2
case .centerY: frame.origin.y = value - height/2
default: break
}
self = frame
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/UIView+Installer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import ObjectiveC

public let DEFAULT_STATE = "DEFAULT STATE"

fileprivate var stateTypeAssociationKey: UInt8 = 0
fileprivate var nxStateTypeAssociationKey: UInt8 = 1
private var stateTypeAssociationKey: UInt8 = 0
private var nxStateTypeAssociationKey: UInt8 = 1

public extension UIView {

Expand Down

0 comments on commit 6d55b3a

Please sign in to comment.