Skip to content

Commit

Permalink
Merge pull request #73 from boostcampwm-2024/fix/DesginSystem
Browse files Browse the repository at this point in the history
[Fix] Desgin System Layout 수정
  • Loading branch information
choijungp authored Nov 12, 2024
2 parents 4f3d95d + 0ff97ce commit 9f92b4c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Presentation/Presentation/Sources/Common/Extension/UIView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import UIKit

extension UIView {
@discardableResult
func addToSuperview(_ superview: UIView) -> Self {
superview.addSubview(self)
self.translatesAutoresizingMaskIntoConstraints = false
return self
}

@discardableResult
func top(
equalTo anchor: NSLayoutYAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -27,6 +29,7 @@ extension UIView {
return self
}

@discardableResult
func top(
equalTo anchor: NSLayoutYAxisAnchor,
inset: CGFloat = 0,
Expand All @@ -38,6 +41,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func bottom(
equalTo anchor: NSLayoutYAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -51,6 +55,7 @@ extension UIView {
return self
}

@discardableResult
func bottom(
equalTo anchor: NSLayoutYAxisAnchor,
inset: CGFloat = 0,
Expand All @@ -62,6 +67,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func leading(
equalTo anchor: NSLayoutXAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -75,6 +81,7 @@ extension UIView {
return self
}

@discardableResult
func leading(
equalTo anchor: NSLayoutXAxisAnchor,
inset: CGFloat = 0,
Expand All @@ -86,6 +93,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func trailing(
equalTo anchor: NSLayoutXAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -99,6 +107,7 @@ extension UIView {
return self
}

@discardableResult
func trailing(
equalTo anchor: NSLayoutXAxisAnchor,
inset: CGFloat = 0,
Expand All @@ -110,6 +119,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func width(equalTo constant: CGFloat, priority: UILayoutPriority = .required) -> Self {
let constraint = self
.widthAnchor
Expand All @@ -119,6 +129,7 @@ extension UIView {
return self
}

@discardableResult
func height(equalTo constant: CGFloat, priority: UILayoutPriority = .required) -> Self {
let constraint = self
.heightAnchor
Expand All @@ -128,6 +139,7 @@ extension UIView {
return self
}

@discardableResult
func size(
width: CGFloat,
height: CGFloat,
Expand All @@ -138,6 +150,7 @@ extension UIView {
.height(equalTo: height, priority: priority)
}

@discardableResult
func centerX(
equalTo anchor: NSLayoutXAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -151,6 +164,7 @@ extension UIView {
return self
}

@discardableResult
func centerY(
equalTo anchor: NSLayoutYAxisAnchor,
constant: CGFloat = 0,
Expand All @@ -164,12 +178,14 @@ extension UIView {
return self
}

@discardableResult
func center(in view: UIView, priority: UILayoutPriority = .required) -> Self {
return self
.centerX(equalTo: view.centerXAnchor, priority: priority)
.centerY(equalTo: view.centerYAnchor, priority: priority)
}

@discardableResult
func edges(
equalTo view: UIView,
inset: CGFloat = 0,
Expand All @@ -194,6 +210,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func horizontalEdges(
equalTo view: UIView,
inset: CGFloat = 0,
Expand All @@ -210,6 +227,7 @@ extension UIView {
priority: priority)
}

@discardableResult
func verticalEdges(
equalTo view: UIView,
inset: CGFloat = 0,
Expand Down

0 comments on commit 9f92b4c

Please sign in to comment.