美文网首页
SwiftUI 2.0 使用 @ScaleMetric 与系统字

SwiftUI 2.0 使用 @ScaleMetric 与系统字

作者: 刘铁崧 | 来源:发表于2021-02-17 21:31 被阅读0次

    当手机字体调大,APP字体与系统字体联动

    struct ContentView: View {
        @ScaledMetric var size:CGFloat = 40
        var body: some View {
            VStack{
                Image(systemName: "message")
                    .resizable()
                    .frame(width: size, height: size, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
                Text("CY")
                    .font(.system(size: size))
            }
        }
    }
    
    • 当修改系统字体尺寸时,即可在app中实现联动


    相关文章

      网友评论

          本文标题:SwiftUI 2.0 使用 @ScaleMetric 与系统字

          本文链接:https://www.haomeiwen.com/subject/hqdwxltx.html