2016-11-29 83 views
1

對於新手的問題感到抱歉。似乎無法在Swift中使用CGRectIntegral和CGInsect函數

但只是要求標題暗示,我似乎無法使用這些函數在迅速3 ..我已經嘗試導入CoreGraphics庫,但沒有vail。

任何人都知道爲什麼?

在此先感謝。

+0

導入CoreGraphics後,它工作正常...我檢查了xcode 8,swift 3 .. –

回答

4

其工作正常,但語法變化

let frame = CGRect.zero 
    let x = frame.integral 
    frame.insetBy(dx: 0, dy: 0) 
+0

謝謝你的回答。哦,好吧..我現在得到它..謝謝一堆! – user3608914

+0

我還沒有檢查,但我想你可以像這樣使用 attributes.frame = attributes.frame.integral –

0

其實你並不需要導入CoreGraphics中。

在夫特3 Objective-C的功能

CGRect CGRectIntegral(CGRect rect) 

已成爲

var integral: CGRect { get } 

CGRect CGRectInset(CGRect rect, CGFloat dx, CGFloat dy); 

已成爲

func insetBy(dx: CGFloat, dy: CGFloat) -> CGRect 

兩個API已對CGRect實例調用例如

let newFrame = view.frame.insetBy(dx: 10.0, dy:10.0) 

一個提示,找出自己

  • ⇧⌘0
  • 類型CGRectIn在搜索字段
  • 在彈出菜單語言設置爲目標C
  • 選擇的功能
  • 設置語言斯威夫特
  • 一個
+0

非常感謝! – user3608914

2
  1. 進口CoreGraphics在

  2. let rect = CGRect() let rectIntegral = rect.integral

謝謝:)