1

I can't seem to set the layer.borderColor in XCode.

Most resources online seem to indicate that borderColor is of type CGColor, and that XCode applies UIColors. They say you can get around this by using proxy properties, but they only offer guides in Objective C and Swift:

Is it possible to set UIView border properties from interface builder?

C# has no concept of extension properties, meaning I can't port the above code.

I've made sure my border width is set to 1, which makes a black border appear around the UITextField.

Is there anyway to achieve this from the storyboard or xib file, rather than doing it programatically?

Community
  • 1
  • 1
Chucky
  • 1,701
  • 7
  • 28
  • 62

1 Answers1

2

You can open the storyboard file in the Xcode interface builder to set them there. The changes should reflect over into Xamarin.

Alternatively, if what you're having trouble with is just using a CGColor for layer.BorderColor, you can simply get the CGColor property from your UIColor.

As an example:

view.layer.BorderColor = UIColor.Black.CGColor;
Timothy James
  • 1,062
  • 13
  • 25
  • I went with the second option, though I would have liked to be able to do it from storyboard User Defined Runtime Attributes in XCode, like you suggested. Not going to mark this as right until I know there is no other way to do this. But thank you, Timothy. – Chucky Jul 12 '16 at 12:02
  • Did you try opening the storyboard file from Xcode as opposed to doing it from Xamarin? – Timothy James Jul 13 '16 at 18:02
  • You mean run up an instance of XCode, and open it from the dialog within there? I have not tried that yet. Will that be different from opening XCode from within Xamarin? – Chucky Jul 14 '16 at 12:22
  • Yes, that's what I mean. I've never opened Xcode from within Xamarin, so I'm not sure. – Timothy James Jul 14 '16 at 18:10