Recently I have downloaded the new XCode 6 beta version.In the apple docs it is saying that we can see the output while editing the Code in .swift file without build and run. I haven't find any ways to fulfill the live rendering. Could you please help me out on this? Thanks in advance
It's important that you set up your project as a cocoa touch framework!
Then:
1.) Add @IBDesignable to your custom UIView before the class definition. (It might be helpful to override the drawInRect function for the beginning.)
2.) Add a UIView object to your .xib or .storyboard file at it change its class to your customView with the @IBDesignable attribute.
It should work.
Tipp: Check out this years WWDC video: "What's New to Interface Builder in Xcode 6" - There is explained how to set it up.
You actually do not have to create Cocoa Touch framework. If you create a custom view with nib that contains UI elements and show them another view just add the code below to your custom view
-(instancetype)initWithFrame:(CGRect)frame{
#if !TARGET_INTERFACE_BUILDER
self= [super initWithFrame:frame];
if(self){
}
return self;
#else
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
return [bundle loadNibNamed:NSStringFromClass([self class]) owner:self options:nil][0];
#endif
}
Since you don't have your main bundle while you are on design mode, you won't be able to retrieve your custom view to render. In addition to this, if you have extra properties and set them onto your ui elements, you may do this within method
-(void)prepareForInterfaceBuilder{
}
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