2015-10-18 152 views
-1

設置的UIView BORDERCOLOR我想我UIView的layer.borderColor屬性設置爲這樣一個自定義的UIColor:麻煩iOS9.0

groupPageView.layer.borderColor = [UIColor colorWithRed:203.0 green:17.0 blue:17.0 alpha:1] 

,它是行不通的。什麼是簡單的方法來實現這一點? Xcode建議我投它CGColorRef,但這不起作用。

+0

「的Xcode建議我投它CGColorRef,但這不起作用「。不過,Xcode是正確的。 – matt

+0

但它沒有正確施放它。每次都是黑色的。 – Chisx

回答

1

像這樣:

groupPageView.layer.borderColor = [[UIColor colorWithRed:203.0/255.0 green:17.0/255.0 blue:17.0/255.0 alpha:1] CGColor] 
+0

這不起作用 – Chisx

+0

因爲你的價值觀不好。 '1'上面的所有內容都是黑色的。所以這是黑色的。 – matt

+0

顏色組件需要在0.0 - 1.0範圍內。 – rmaddy

0

1確保您導入

#import <UIKit/UIKit.h> 

再加入這個2線

groupPageView.layer.borderColor = [UIColor colorWithRed:203.0 green:17.0 blue:17.0 alpha:1].CGColor 
groupPageView.layer.borderWidth =2.0;//default width =0 ; so if not set you will not see border colour