What is the mean by “User Defined Runtime Attributes” ?
“User Defined Runtime Attributes” are featured from Xcode 4 and iOS 5, great feature supported in interface builder. But bad thing is that most of the intermediate developers are not aware about it.
Where can I found in Interface builder ?
take a look under Identity Inspector tab.
Key Path- Its like properties of controls and or setter methods.
Value- Assigned values to those properties and or setter methods.
What about the 'Type' ?
Below are the supported Attributes types
Lets come to the point.
How can we use these in our application.
It is not possible to set a View's CornerRadius or borderWidth using interface builder's Attributes Inspector. To achieve this we unnecessarily creates a IBOutlet and use CALayer for this.
like
_myBGview.layer.borderWidth = 3;
_myBGviewlayer.cornerRadius = 15;
Lets do the same using Interface builder
Wow its so simple Just fill out the objects property and select type and set the value
One problem is here that I required to set the color of the border but CALayer's color is CGColorRef type not UIColor type
So we can use a trick of Objective-C's Category. Just implement a setter method.
@implementation CALayer (Enhancement)
-(void)setMycolorFromcolor:(UIColor*)mycolor
{
self.borderColor = mycolor.CGColor;
}
Its all about Using User Defined Runtime Attributes from my side. If you have any other best way to configure User Defined Runtime Attributes in Interface builder
Please share using comments section.
It would be much appreciated.
“User Defined Runtime Attributes” are featured from Xcode 4 and iOS 5, great feature supported in interface builder. But bad thing is that most of the intermediate developers are not aware about it.
Where can I found in Interface builder ?
take a look under Identity Inspector tab.
Key Path- Its like properties of controls and or setter methods.
Value- Assigned values to those properties and or setter methods.
What about the 'Type' ?
Below are the supported Attributes types
Lets come to the point.
How can we use these in our application.
It is not possible to set a View's CornerRadius or borderWidth using interface builder's Attributes Inspector. To achieve this we unnecessarily creates a IBOutlet and use CALayer for this.
like
_myBGview.layer.borderWidth = 3;
_myBGviewlayer.cornerRadius = 15;
Lets do the same using Interface builder
Wow its so simple Just fill out the objects property and select type and set the value
One problem is here that I required to set the color of the border but CALayer's color is CGColorRef type not UIColor type
So we can use a trick of Objective-C's Category. Just implement a setter method.
@implementation CALayer (Enhancement)
-(void)setMycolorFromcolor:(UIColor*)mycolor
{
self.borderColor = mycolor.CGColor;
}
Its all about Using User Defined Runtime Attributes from my side. If you have any other best way to configure User Defined Runtime Attributes in Interface builder
Please share using comments section.
It would be much appreciated.
No comments:
Post a Comment