iOS Create a Label and use bundle

first  lock the code:

 

 

{

 

    [super
viewDidLoad];

 

    NSBundle * mainBundle = [NSBundle
mainBundle];

 

    NSString * imagePath = [mainBundle
pathForResource
:@”QQ20130912-1″ ofType:@”png”];

 

    NSLog(@”%@”, imagePath);

 

 

    UIImage *image = [[UIImage
alloc] initWithContentsOfFile:imagePath];

 

    UIImageView *imageView = [[UIImageView
alloc] initWithImage:image];

 

    [imageView setFrame:CGRectMake(0,
20, 320, 100)];

 

    [self.view
addSubview
:imageView];

 

    [image release];

 

    [imageView release];

 

// Do any additional setup after loading the view.

 

 

 

    UIView *contentView = [[UIView
alloc] initWithFrame:[[UIScreen
mainScreen] applicationFrame]];

 

    contentView.backgroundColor = [UIColor
blackColor];

 

    self.view = contentView;

 

    [contentView release];

 

    CGRect labelFrame = CGRectMake(40.0f,
200.0f, 240.0f,
60.0f
);

 

    UILabel *frontLabel = [[UILabel
alloc] initWithFrame:labelFrame];

 

    frontLabel.text = @”Hello World!”;

 

    frontLabel.font = [UIFont
fontWithName:@”Georgia”
size
:24.0f];

 

    frontLabel.textColor = [UIColor
colorWithRed:0.82f
green
:1.0f blue:0.286f
alpha:1.0f];

 

    frontLabel.backgroundColor = [UIColor
colorWithRed:0.0f
green
:0.0f blue:0.0f
alpha:0.0f];

 

    [contentView addSubview:frontLabel];

 

    [frontLabel release];

 

 

 

}

 

 

 

use this ,you can know how a bundle work!!

 

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注