Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios SwiftUI视图与UIKit UIView类似,如何更改图像的大小_Ios_Swift_Swiftui - Fatal编程技术网

Ios SwiftUI视图与UIKit UIView类似,如何更改图像的大小

Ios SwiftUI视图与UIKit UIView类似,如何更改图像的大小,ios,swift,swiftui,Ios,Swift,Swiftui,swiftui中是否有类似于UIKit UIView的视图 swiftui中有一个EmptyView,有人知道该视图的功能吗 Image("image") .resizable() .aspectRatio(3/2, contentMode: .fill) 这会弄乱图像。是否有其他方法可以在SwiftUI中调整图像大小,颜色、文本、图像等基本视图的行为与UIView类似。要更改图像大小,只需先给它一个帧并使其可调整大小() struct Cont

swiftui中是否有类似于UIKit UIView的视图

swiftui中有一个
EmptyView
,有人知道该视图的功能吗

        Image("image")
        .resizable()
        .aspectRatio(3/2, contentMode: .fill)

这会弄乱图像。是否有其他方法可以在SwiftUI中调整图像大小,颜色、文本、图像等基本视图的行为与UIView类似。要更改图像大小,只需先给它一个帧并使其可调整大小()

struct ContentView : View {

    var body: some View {

         Image("your image name")
            .resizable()
            .frame(width: 300, height: 300)
    }
}

希望能有所帮助。

在SwiftUI中,更改图像大小有两种方法

1) 使其大小可调,并为图像提供一些框架

   Image("image name")
      .resizable()
      .frame(width: 10, height: 10, alignment: .center)
2) 使其可调整大小并可缩放为适合图像的属性

   Image("image name")
      .resizable()
      .scaledToFit()
更多的图片定制请看下面的链接


我希望它能帮助你

比较thnx@ielyamania您确定
文本
是可调整大小的
吗?