I read on the same site how to insert UILabel (subclass UILabel and override the necessary methods). Before adding it to my application, I decided to test it in a standalone test application. The code is shown below.
Here is MyUILabel.h
Here is MyUILabel.m
#import "MyUILabel.h" #import <QuartzCore/QuartzCore.h> @implementation MyUILabel - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } // for border and rounding -(void) drawRect:(CGRect)rect { self.layer.cornerRadius = 4.0; self.layer.borderWidth = 2; [super drawRect:rect]; } // for inset -(void) drawTextInRect:(CGRect)rect { UIEdgeInsets insets = {0, 5, 0, 5}; [super drawTextInRect: UIEdgeInsetsInsetRect(rect, insets)]; }
Here is my ViewController.h
Here is ViewController.m:
None of the methods in MyUILabel.m (which overrides Im) are called.
Understanding why we value so much.
Hi,
Ramon
source share