Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,20 @@ class DetailCollectionViewCell: UICollectionViewCell {
}

private func setStyle() {
locationLabel.do {
$0.font = .sfRegular(size: 36)
$0.textColor = .white
}
locationLabel.setupLabel(font: .sfRegular(size: 36), textColor: .white)

temperatureLabel.do {
$0.font = .sfThin(size: 102)
$0.textColor = .white
}
temperatureLabel.setupLabel(font: .sfThin(size: 102), textColor: .white)

conditionLabel.do {
$0.font = .sfRegular(size: 24)
$0.textColor = .white
}
conditionLabel.setupLabel(font: .sfRegular(size: 24), textColor: .white)

temperatureStackView.do {
$0.axis = .horizontal
$0.spacing = 8
$0.distribution = .equalSpacing
}

minTemperatureLabel.do {
$0.font = .sfMedium(size: 20)
$0.textColor = .white
}

maxTemperatureLabel.do {
$0.font = .sfMedium(size: 20)
$0.textColor = .white
}

minTemperatureLabel.setupLabel(font: .sfMedium(size: 20), textColor: .white)

maxTemperatureLabel.setupLabel(font: .sfMedium(size: 20), textColor: .white)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ class TenDaysForecastCollectionViewCell: UICollectionViewCell {


private func setStyle() {
dayNameLabel.do {
$0.font = .sfMedium(size: 22)
$0.textColor = .white
}
dayNameLabel.setupLabel(font: .sfMedium(size: 22), textColor: .white)

conditionStackView.do {
$0.axis = .vertical
Expand All @@ -82,20 +79,11 @@ class TenDaysForecastCollectionViewCell: UICollectionViewCell {
$0.tintColor = .white
}

precipPercentLabel.do {
$0.font = .sfMedium(size: 15)
$0.textColor = UIColor(red: 0.506, green: 0.812, blue: 0.98, alpha: 1)
}

minTempLabel.do {
$0.font = .sfMedium(size: 22)
$0.textColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
}
precipPercentLabel.setupLabel(font: .sfMedium(size: 15), textColor: UIColor(red: 0.506, green: 0.812, blue: 0.98, alpha: 1))

minTempLabel.setupLabel(font: .sfMedium(size: 22), textColor: UIColor(red: 1, green: 1, blue: 1, alpha: 1))

maxTempLabel.do {
$0.font = .sfMedium(size: 22)
$0.textColor = UIColor(red: 1, green: 1, blue: 1, alpha: 1)
}
maxTempLabel.setupLabel(font: .sfMedium(size: 22), textColor: UIColor(red: 1, green: 1, blue: 1, alpha: 1))
}

func bindData(data: TenDaysForecastData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,9 @@ class TodayForecastCollectionViewCell: UICollectionViewCell {
$0.distribution = .equalSpacing
}

timeLabel.do {
$0.font = .sfMedium(size: 17)
$0.textColor = .white
$0.textAlignment = .center
}
timeLabel.setupLabel(font: .sfMedium(size: 17), textColor: .white)

temperatureLabel.do {
$0.font = .sfMedium(size: 17)
$0.textColor = .white
$0.textAlignment = .center
}
temperatureLabel.setupLabel(font: .sfMedium(size: 17), textColor: .white)

self.contentView.do {
$0.backgroundColor = .clear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class TenDaysCollectionHeaderView: UICollectionReusableView {
$0.tintColor = UIColor.lightGray
}

headerTextLabel.do {
$0.text = "10μΌκ°„μ˜ 일기예보"
$0.font = .sfMedium(size: 15)
$0.textColor = UIColor.lightGray
}
headerTextLabel.setupLabel(font: .sfMedium(size: 15), text:"10μΌκ°„μ˜ 일기예보", textColor: UIColor.lightGray )
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class TodayCollectionHeaderView: UICollectionReusableView {
$0.tintColor = UIColor.lightGray
}

headerTextLabel.do {
$0.text = "μ‹œκ°„λ³„ 일기예보"
$0.font = .sfMedium(size: 15)
$0.textColor = UIColor.lightGray
}
headerTextLabel.setupLabel(font: .sfMedium(size: 15), text: "μ‹œκ°„λ³„ 일기예보", textColor: UIColor.lightGray)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,35 +84,12 @@ class CardCollectionViewCell: UICollectionViewCell {
$0.isUserInteractionEnabled = true
}

location.do {
$0.font = .sfBold(size: 24)
$0.textColor = .white
}

currentTime.do {
$0.font = .sfMedium(size: 17)
$0.textColor = .white
}

currentCondition.do {
$0.font = .sfMedium(size: 16)
$0.textColor = .white
}

maxTemperature.do {
$0.font = .sfMedium(size: 15)
$0.textColor = .white
}

minTemperature.do {
$0.font = .sfMedium(size: 15)
$0.textColor = .white
}

currentTemperature.do {
$0.font = .sfLight(size: 52)
$0.textColor = .white
}
location.setupLabel(font: .sfBold(size: 24), textColor: .white)
currentTime.setupLabel(font: .sfMedium(size: 17), textColor: .white)
currentCondition.setupLabel(font: .sfMedium(size: 16), textColor: .white)
maxTemperature.setupLabel(font: .sfMedium(size: 15), textColor: .white)
minTemperature.setupLabel(font: .sfMedium(size: 15), textColor: .white)
currentTemperature.setupLabel(font: .sfLight(size: 52), textColor: .white)
}

func configureCell(data: WeatherListModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,39 +75,12 @@ class WeatherCardView: UIButton {
$0.layer.cornerRadius = 16
$0.isUserInteractionEnabled = true
}

myLocation.do {
$0.text = "λ‚˜μ˜ μœ„μΉ˜"
$0.font = .sfBold(size: 24)
$0.textColor = .white
}

currentLocation.do {
$0.text = "κ³ μ–‘μ‹œ"
$0.font = .sfMedium(size: 17)
$0.textColor = .white
}

currentCondition.do {
$0.text = "흐림"
$0.font = .sfMedium(size: 16)
$0.textColor = .white
}

maxTemperature.do {
$0.text = "졜고:29°"
$0.font = .sfMedium(size: 15)
$0.textColor = .white
}
minTemperature.do {
$0.text = "μ΅œμ €:15Β°"
$0.font = .sfMedium(size: 15)
$0.textColor = .white
}
currentTemperature.do {
$0.text = "21Β°"
$0.font = .sfLight(size: 52)
$0.textColor = .white
}

myLocation.setupLabel(font: .sfBold(size: 24), textColor: .white)
currentLocation.setupLabel(font: .sfMedium(size: 17), textColor: .white)
currentCondition.setupLabel(font: .sfMedium(size: 16), textColor: .white)
maxTemperature.setupLabel(font: .sfMedium(size: 15), textColor: .white)
minTemperature.setupLabel(font: .sfMedium(size: 15), textColor: .white)
currentTemperature.setupLabel(font: .sfLight(size: 52), textColor: .white)
}
}
62 changes: 62 additions & 0 deletions weather-app/weather-app/Resources/Extensions/UILabel+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// UILabel+.swift
// weather-app
//
// Created by μœ€μ˜μ„œ on 12/15/23.
//

import UIKit

extension UILabel {

func highlightText(forText: String, forColor: UIColor) {
guard let labelText = self.text else { return }
let attributedString = NSMutableAttributedString(string: labelText)

let range = (labelText as NSString).range(of: forText)
attributedString.addAttribute(.foregroundColor, value: forColor, range: range)

self.attributedText = attributedString
}

func underLineText(forText: [String]) {
guard let labelText = self.text else { return }

let underLineText = NSMutableAttributedString(string: labelText)

for text in forText {
let range = (labelText as NSString).range(of: text)
underLineText.addAttribute(NSAttributedString.Key.underlineStyle, value: NSUnderlineStyle.single.rawValue, range: range)
}

self.attributedText = underLineText
}

func labelWithImg(composition: NSAttributedString...) {
let attributedString = NSMutableAttributedString()
for i in composition {
attributedString.append(i)
attributedString.append(NSAttributedString(string: " "))
}
self.attributedText = attributedString
}

func setupLabel(font: UIFont, text: String? = nil, textColor: UIColor, alignment: NSTextAlignment = .center) {
self.font = font
self.text = text
self.textColor = textColor
self.textAlignment = alignment
}

func setupRoundedLabel(text: String, font: UIFont, textColor: UIColor, alignment: NSTextAlignment, bgColor: UIColor, borderColor: UIColor, borderWidth: CGFloat, radius: CGFloat) {
self.text = text
self.font = font
self.textColor = textColor
self.textAlignment = alignment
self.backgroundColor = bgColor
self.layer.borderColor = borderColor.cgColor
self.layer.borderWidth = borderWidth
self.layer.cornerRadius = radius
self.layer.masksToBounds = true
}
}