This is my code that run but show white screen.
#import <UIKit/UIKit.h>
@interface myView : UIView {
UILabel *touchPhaseText;
}
@property (nonatomic, retain) UILabel *touchPhaseText;
@end
#import "myView.h"
@implementation myView
@synthesize touchPhaseText;
- (id)initWithFrame
CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor =[UIColor blackColor];
// Set up a text label to show the touch phase.
// Create and inialize the label.
touchPhaseText = [self newLabelWithOffset
self.frame.origin.y + 25) numberOfLines: 1];
// Set the default text that shows on startup.
touchPhaseText.text = @"Touches lets you observe touch";
// Add the label as a subview.
[self addSubview:touchPhaseText];
}
return self;
}
-(UILabel *) newLabelWithOffset
float)offset numberOfLines
NSUInteger) lines
{
float textHeight = 20.0;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.origin.x + 10.0, offset, self.frame.size.width - 20.0, textHeight * lines)];
// Set the font size, text color, background color, and alignment.
label.font = [UIFont systemFontOfSize:18.0];
label.textColor = [UIColor lightTextColor];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
// Set the number of lines
label.numberOfLines = lines;
if (lines > 1)
// Set the linebreak mode if there is more than one line.
label.lineBreakMode = UILineBreakModeWordWrap;
// Initialize as an empty string
label.text = @"";
return label;
}
- (void)drawRect
CGRect)rect {
// Drawing code
}
- (void)dealloc {
[super dealloc];
}
@end