forked from codesquad-members-2021/sidedish
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add BadgeStackView in BanchanCustomCell
반찬 커스텀셀에 특가 배지 넣기위해 BadgeStaciView를 추가하였습니다. issue: #12
- Loading branch information
1 parent
624cf29
commit 51bb2ee
Showing
6 changed files
with
112 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.76 KB
(100%)
iOS/SideDish/SideDish.xcworkspace/xcuserdata/shim.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// BadgeLabel.swift | ||
// SideDish | ||
// | ||
// Created by 지북 on 2021/04/22. | ||
// | ||
|
||
import UIKit | ||
|
||
class BadgeLabel: UILabel { | ||
|
||
private let topInset: CGFloat = 4.0 | ||
private let bottomInset: CGFloat = 4.0 | ||
private let leftInset: CGFloat = 8.0 | ||
private let rightInset: CGFloat = 8.0 | ||
|
||
let badgeColors: [String:UIColor] = ["이벤트특가": UIColor(displayP3Red: 130/255, green: 211/255, blue: 45/255, alpha: 1), "론칭특가": UIColor(displayP3Red: 134/255, green: 198/255, blue: 255/255, alpha: 1)] | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
} | ||
|
||
func configure(text badgeText: String) { | ||
translatesAutoresizingMaskIntoConstraints = false | ||
font = UIFont.systemFont(ofSize: 12, weight: .regular) | ||
textColor = .white | ||
backgroundColor = badgeColors[badgeText] | ||
text = badgeText | ||
clipsToBounds = true | ||
layer.cornerRadius = 5 | ||
} | ||
|
||
override func drawText(in rect: CGRect) { | ||
let insets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset) | ||
super.drawText(in: rect.inset(by: insets)) | ||
} | ||
|
||
override var intrinsicContentSize: CGSize { | ||
let size = super.intrinsicContentSize | ||
return CGSize(width: size.width + leftInset + rightInset, | ||
height: size.height + topInset + bottomInset) | ||
} | ||
} |