2017-06-27 8 views
0

かなり長い間ボタンの境界線を取得しようとしています。Objective-C:ボタンの境界線の色が表示されません。

[self.accountButton.layer setBorderColor:(__bridge CGColorRef _Nullable)UIColorFromRGB(kGABrandingGreenColor)]; 

これは、色の値が生成される方法です。

#define UIColorFromRGB(rgbValue) ([UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 
               green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 
               blue:((float)(rgbValue & 0xFF))/255.0 \ 
               alpha:1.0]) 

#define kGABrandingGreenColor  (0x53C2BE) 

私の問題を解決する解決策が見つかりませんでした。

答えて

2

それはちょうど橋を定義して、削除に.CGColorを追加し、あなたが近くにいる簡単

#define UIColorFromRGB(rgbValue) \ 
[UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \ 
blue:((float)((rgbValue & 0x0000FF) >> 0))/255.0 \ 
alpha:1.0] 

#define kGABrandingGreenColor  (0xBC1128) 


[self.accountButton.layer setBorderWidth:3.0]; 
[self.accountButton.layer setBorderColor:[UIColorFromRGB(kGABrandingGreenColor) CGColor]]; 
+0

ありがとうございました! –

0

です。 borderWidthを設定する必要があります。それ以外の場合は何も表示されません。

#define UIColorFromRGB(rgbValue) ([UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 
              green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 
              blue:((float)(rgbValue & 0xFF))/255.0 \ 
              alpha:1.0]).CGColor 

#define kGABrandingGreenColor  (0x53C2BE) 


[self.accountButton.layer setBorderColor:UIColorFromRGB(kGABrandingGreenColor)]; 
self.accountButton.layer.borderWidth = 2.0f; 
関連する問題