簡體   English   中英

Swift轉換,CGFloat轉換為Integer

[英]Swift conversions, CGFloat to Integer

你如何將@IValue CGFloat轉換為Int?

我不斷得到一個cannot convert @IValue CGFloat to Integer的方法如下:

@IBOutlet var userObject : UIImageView


func returnYPosition(yPosition: Integer) -> Integer {
    return userObject.center.y
}

你需要來回傳遞Int類型,然后才轉換:

func returnYPosition(yPosition: Int) -> Int {
    return Int(userObject.center.y)
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM