IOS学习日记二

把想要设置的图片拉到 Assets.xcassets里面

doge

File > New > File中新建一个SwiftUI View的文件,我这里将其命名为CircleImage.swift

用Image来展示该图

import SwiftUI

struct CircleImage: View {
    var body: some View {
        Image("dogHead") // 只需要名字
    }
}

struct CircleImage_Previews: PreviewProvider {
    static var previews: some View {
        CircleImage()
    }
}

.clipShape(Circle())使得切割图像为圆形

var body: some View {
        Image("Doggie")
            .clipShape(Circle())
    }

The Circle type is a shape that you can use as a mask, or as a view by giving the circle a stroke or fill.

an overlay

使用overlay来给外围的圆圈添加参数

Color-> 颜色

LineWidth-> 线宽

.shadow() -> 增加阴影

struct CircleImage: View {
    var body: some View {
        Image("Doggie")
            .clipShape(Circle())
            .overlay(
                Circle().stroke(Color.gray, lineWidth: 4))
            .shadow(radius: 10)
    }
}

新建一个文件并引入MapKit

发表评论

邮箱地址不会被公开。 必填项已用*标注