小编sub*_*dan的帖子

如何在Swift中将十进制数转换为二进制?

如何在Swift中将Int转换为UInt8?例.我想将22号转换为0b00010110

var decimal = 22
var binary:UInt8 = ??? //What should I write here?
Run Code Online (Sandbox Code Playgroud)

swift

49
推荐指数
6
解决办法
4万
查看次数

How to resize Image with SwiftUI?

I have a large image in Assets.xcassets. How to resize this image with SwiftUI to make it small?

I tried to set frame but it doesn't work:

Image(room.thumbnailImage)
    .frame(width: 32.0, height: 32.0)
Run Code Online (Sandbox Code Playgroud)

ios swift swiftui

38
推荐指数
15
解决办法
1万
查看次数

How to set custom highlighted state of SwiftUI Button

I have a Button. I want to set custom background color for highlighted state. How can I do it in SwiftUI?

在此处输入图片说明

Button(action: signIn) {
    Text("Sign In")
}
.padding(.all)
.background(Color.red)
.cornerRadius(16)
.foregroundColor(.white)
.font(Font.body.bold())
Run Code Online (Sandbox Code Playgroud)

swiftui

11
推荐指数
3
解决办法
2565
查看次数

如何在Swift中将十六进制数转换为bin?

我有字符串变量:var str ="239A23F"如何将此字符串转换为二进制数? str.toInt()不起作用.

binary hex swift

10
推荐指数
1
解决办法
6648
查看次数

如果let没有为MKAnnotation的title属性解包可选值

我想用if-let语句解包可选值.我需要获得MKAnnotation的标题.

func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    if let title = view.annotation?.title {
        print(title) //Optional("Moscow")
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么if-let在这里不起作用?

mkannotation ios swift

0
推荐指数
1
解决办法
95
查看次数

标签 统计

swift ×4

ios ×2

swiftui ×2

binary ×1

hex ×1

mkannotation ×1