A Swift package providing some view for SwiftUI.
- Copyright: ©Jaesung Lee.
- Xcode 12+
- iOS13+ (Some features may require iOS14)
URLImage("https://someurl")
The view that shows image based on URL.
IMPORTANT You have to set
URLImage.defaultName
before loading URL image. I recommend that you set the value inside of initializer.
BlurView(style: .regular)
The view that has blur effect. This view allows you to blur a specific area
Corner(alignment: .bottomRight) {
// Content
Text("Swift@Night")
}
The view that moves content to a specific corner.
Image("backgroundImage")
.resizedToFill(width: 100, height: 50)
- resizedToFit: Resize image and adjust aspect ratio as
.fit
. You don't need to callresizable()
- resizedToFill: Resize image and adjust aspect ratio as
.fill
. You don't need to callresizable()
NOTE When you set width value only, the image shows square image.
Xcode > File > Swift Packages > Add Package Dependency > Enter repository URL: https://github.com/Swift-at-Night/ElViewKit
IMPORTANT The version of the package must be
0.1.2
or later
- Example
import ElViewKit
import SwiftUI
struct SomeView: View {
var body: some View {
ZStack {
// Image Modifier
Image("backgroundImage")
.resizedToFill(width: UIScreen.main.bounds.width,
height: UIScreen.main.bounds.height)
.edgesIgnoringSafeArea(.all)
// Blur View
BlurView(style: .regular).edgesIgnoringSafeArea(.all)
// URL Image
URLImage("https://avatars1.githubusercontent.com/u/68183707?s=200&v=4")
.frame(width: 100, height: 100)
.clipped()
.overlay (
// Corner
Corner(alignment: .bottomRight) {
Image(systemName: "moon.circle.fill")
.resizedToFill(width: 50)
.foregroundColor(.gray)
}
)
}
}
init() {
// URL Image
URLImage.defaultName = "defaultImage"
}
}
Your Swift Package > Package.swift
> Add new package to dependencies
> Add "ElViewKit"
to the target > Then, now you can import ElViewKit
in your source file.
- Example
import PackageDescription
let package = Package(
name: "SomePackage",
products: [
...
],
dependencies: [
.package(url: "https://github.com/Swift-at-Night/ElViewKit", from: "0.1.2") // 1. Add dependency to your swift package
],
targets: [
.target(
name: "SomePackage",
dependencies: ["ElViewKit"]), // 2. Add ElViewKit to the target as dependency
.testTarget(...),
]
)