I have added a XIB based UIViewController
to my solution and dragged some UIViews
into it.
Now I want some of the views not to be UIView
but RoundedRectView
(https://github.com/Krumelur/RoundedRectView) which inherits from UIView
.
How to achieve this? I tried to change the class in Interface Builder but that did nothing. Then I manually modified the designer.cs file but that resulted in a failure. Then I tried modifying the fake ObjC code but that failed too.
(I'm using Xcode 4.2 and MD 2.8.6.4)
Creating Custom Views programatically. Open Xcode ▸ File ▸ New ▸ File ▸ Cocoa Touch class ▸ Add your class name ▸ Select UIView or subclass of UIView under Subclass of ▸ Select language ▸ Next ▸ Select target ▸ Create the source file under your project directory.
Your view subclass needs at least two things:
Register attribute
[Register("MyView")]
public class MyView : UIView {}
IntPtr constructor
public MyView(IntPtr handle) : base(handle) {}
You then open the XIB in Interface Builder, add a UIView
and set its Class in the Identity Inspector to the name you passed to the Register attribute. When you connect it to an outlet, you will see that it has the correct type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With