LinkPreview(SwiftUI)
Preview with Link’s meta information.
Image | Gif |
Get Started
import SwiftUI
import LinkPreview
struct LinkPreview_Test: View {
@State private var size: CGFloat = 350
var body: some View {
ZStack(alignment: .bottom){
ScrollView{
VStack{
LinkPreview(url: URL(string: "https://github.com/NuPlay/RichText"))
.backgroundColor(.blue)
.primaryFontColor(.white)
.secondaryFontColor(.white.opacity(0.6))
.titleLineLimit(3)
.frame(width: size, alignment: .center)
LinkPreview(url: URL(string: "https://github.com/NuPlay/ExpandableText"))
.titleLineLimit(20)
.frame(width: size, alignment: .center)
.type(.small)
LinkPreview(url: URL(string: "https://github.com/NuPlay/SwiftUI-SlideText"))
}
.padding(.horizontal, 24)
}
Slider(value: $size , in: 100...400, step: 1)
.padding(.horizontal, 24)
}
}
}
Modifier(optional)
Modifier | Default |
---|---|
.backgroundColor(_ backgroundColor: Color) |
Color(.systemGray5) |
.primaryFontColor(_ primaryFontColor: Color) |
.primary |
.secondaryFontColor(_ secondaryFontColor: Color) |
.gray |
.titleLineLimit(_ titleLineLimit: Int) |
3 |
.type(_ type: LinkPreviewType(customType[.large, .small, .auto])) |
.auto |