Skip to content

Commit

Permalink
[Feat] #6 - UIImage symbol weight 함수 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
yurim830 committed Oct 25, 2024
1 parent 6b4a67a commit de8ae7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ extension UIButton {
fontSize: CGFloat = 15,
fontWeight: UIFont.Weight = .regular,
systemName: String = "",
pointSize: CGFloat? = nil,
symbolWeight: UIImage.SymbolWeight = .unspecified,
cornerStyle: UIButton.Configuration.CornerStyle? = nil,
foregroundColor: UIColor = .tintColor,
Expand All @@ -40,7 +41,7 @@ extension UIButton {
self.setAttributedTitle(attributedTitle, for: state)
}

config.image = UIImage.configureImage(systemName: systemName, symbolWeight: symbolWeight)
config.image = UIImage.configureImage(systemName: systemName, pointSize: pointSize, symbolWeight: symbolWeight)

if let cornerStyle = cornerStyle {
config.cornerStyle = cornerStyle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
import UIKit

extension UIImage {
class func configureImage(systemName: String, symbolWeight: UIImage.SymbolWeight) -> UIImage? {
class func configureImage(systemName: String, pointSize: CGFloat? = nil, symbolWeight: UIImage.SymbolWeight) -> UIImage? {
if let pointSize = pointSize {
let symbolConfig = UIImage.SymbolConfiguration(pointSize: pointSize, weight: symbolWeight)
return UIImage(systemName: systemName, withConfiguration: symbolConfig)
}

let symbolConfig = UIImage.SymbolConfiguration(weight: symbolWeight)
return UIImage(systemName: systemName, withConfiguration: symbolConfig)
}
Expand Down
11 changes: 7 additions & 4 deletions 35-seminar/Presentation/Week2/View/AppDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,15 @@ class AppDetailView: UIView {

openButton.configureButton(configType: .filled,
title: "열기",
fontSize: 16,
fontWeight: .bold,
cornerStyle: .capsule,
foregroundColor: .white,
backgroundColor: .tintColor)

shareButton.configureButton(systemName: "square.and.arrow.up",
symbolWeight: .medium)
pointSize: 16,
symbolWeight: .semibold)

}

Expand Down Expand Up @@ -441,13 +443,14 @@ class AppDetailView: UIView {
openButton.snp.makeConstraints {
$0.leading.equalTo(titleLabel)
$0.bottom.equalTo(iconImageView)
$0.width.equalTo(76)
$0.height.equalTo(34)
$0.width.equalTo(72)
$0.height.equalTo(32)
}

shareButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(20)
$0.bottom.equalTo(iconImageView)
$0.size.equalTo(32)
}
}

Expand Down Expand Up @@ -554,7 +557,7 @@ class AppDetailView: UIView {
previewDeviceImageView.snp.makeConstraints {
$0.top.equalTo(previewImageView.snp.bottom).offset(10)
$0.leading.equalToSuperview()
$0.size.equalTo(20)
$0.size.equalTo(18)
$0.bottom.equalToSuperview().offset(-10)
}

Expand Down

0 comments on commit de8ae7f

Please sign in to comment.