SwiftUI 如何设置下划线和文本的间距? [英] How SwiftUI sets the spacing between the underline and the text?

查看:44
本文介绍了SwiftUI 如何设置下划线和文本的间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置下划线的代码,我想让文字和下划线之间的间距更大.

Code to set underline,I want to make the space between the text and the underline larger.

 Text("underline text")
 .underline()

推荐答案

下划线是一个字体特性,你可以在任何需要的地方画线来自定义下

Underline is a font feature, you can do custom under just by drawing line anywhere needed

var body: some View {
    HStack {
        Text("Before")
        Text("underline text")
            .overlay(
                Rectangle().frame(height: 1).offset(y: 4)
                , alignment: .bottom)
        Text("after.")
    }
}

这篇关于SwiftUI 如何设置下划线和文本的间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆