forked from Cay-Zhang/RSSBud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ButtonStyle.swift
33 lines (29 loc) · 885 Bytes
/
ButtonStyle.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// ButtonStyle.swift
// RSSBud
//
// Created by Cay Zhang on 2020/8/10.
//
import SwiftUI
struct SquashableButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.opacity(configuration.isPressed ? 0.75 : 1)
.scaleEffect(configuration.isPressed ? 0.97 : 1)
}
}
extension View {
func roundedRectangleBackground(color uiColor: UIColor = .tertiarySystemBackground) -> some View {
self.font(Font.body.weight(.semibold))
.foregroundColor(.accentColor)
.padding(.vertical, 10)
.frame(maxWidth: .infinity)
.background(Color(uiColor))
.clipShape(RoundedRectangle(cornerRadius: 8, style: .continuous))
}
}
struct ButtonStyle_Previews: PreviewProvider {
static var previews: some View {
EmptyView()
}
}