2014-09-02 50 views
2

CGRectEdge在CGGeometry.h定義像這樣:CGRectEdge如何用於建立矩形的邊緣?

enum CGRectEdge { 
    CGRectMinXEdge, CGRectMinYEdge, CGRectMaxXEdge, CGRectMaxYEdge 
}; 
typedef enum CGRectEdge CGRectEdge; 

和文檔(在CGGeometry參考)表示,CGRectEdge是「即建立一個矩形的邊緣座標」。那麼設置這些值是什麼?或者如何設定這些值?各個值是隻讀的。這聽起來很有用,但我不明白如何使用它來做任何事情,因爲我看不到如何設置它。也不知道如何將其與特定的矩形關聯。

回答

2

的CGRectEdge枚舉用於提供信息給劃分成矩形子矩形呼叫,這兩個調用在< CoreGraphics中/ CGGeometry.h >和MKMapRectDivide在<MapKit/MKGeometry.h>是CGRectDivide。

/* Make two new rectangles, `slice' and `remainder', by dividing `rect' with 
a line that's parallel to one of its sides, specified by `edge' -- either 
`CGRectMinXEdge', `CGRectMinYEdge', `CGRectMaxXEdge', or 
`CGRectMaxYEdge'. The size of `slice' is determined by `amount', which 
measures the distance from the specified edge. */ 

void CGRectDivide(CGRect rect, CGRect *slice, CGRect *remainder, 
    CGFloat amount, CGRectEdge edge); 

void MKMapRectDivide(MKMapRect rect, MKMapRect *slice, MKMapRect *remainder, double amount, CGRectEdge edge) NS_AVAILABLE(10_9, 4_0); 
+2

綠色檢查,因爲這是更好的2類似的答案,只是因爲它有更多的信息。但這兩個答案都錯過了讓我困惑的東西。從文檔中,我認爲CGRectEdge以某種方式指定了矩形的座標。我現在明白它的價值只是指定矩形的四個邊中的一個。它是用於指定四個邊中的一個的數字代碼。它不給任何事情的座標。文件中的措辭似乎是錯誤的。它不應該說「建立矩形邊的座標」,因爲它不包含座標。 – RobertL 2014-09-02 17:50:15

2

這主要用於我所知道的CGRectDivide

您會通過一個類型的CGRectEdge到參數edge

的邊緣值,指定從 ,其在量參數中傳遞的距離被測量的矩形的一側。 CGRectDivide生成一個「切片」矩形,其中包含指定的邊緣,並將距離延伸至其之外。