-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// Image+.swift | ||
// Score | ||
// | ||
// Created by sole on 4/27/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
//MARK: - Image+imagePlaceHolder | ||
|
||
extension Image { | ||
|
||
//MARK: - imagePlaceHolder | ||
|
||
/// image 플레이스 홀더가 필요한 사진의 경우에 사용합니다. | ||
/// 플레이스 홀더를 원형의 size*size로 생성합니다. | ||
@ViewBuilder | ||
func imagePlaceHolder(size: CGFloat) -> some View { | ||
self | ||
.resizable() | ||
.frame(width: 130, | ||
height: 130) | ||
.clipShape(Circle()) | ||
.background { | ||
Circle() | ||
.frame(width: size, | ||
height: size) | ||
.foregroundStyle( | ||
Color.brandColor(color: .gray2) | ||
) | ||
} | ||
.frame(width: size, | ||
height: size) | ||
} | ||
} | ||
|
||
extension Image? { | ||
|
||
@ViewBuilder | ||
func imagePlaceHolder(size: CGFloat) -> some View { | ||
let image: Image = self ?? Image("") | ||
image | ||
.resizable() | ||
.frame(width: 130, | ||
height: 130) | ||
.clipShape(Circle()) | ||
.background { | ||
Circle() | ||
.frame(width: size, | ||
height: size) | ||
.foregroundStyle( | ||
Color.brandColor(color: .gray2) | ||
) | ||
} | ||
.frame(width: size, | ||
height: size) | ||
} | ||
} |