Skip to content

Label in Code Objective C 1

Azmal Tech edited this page Dec 27, 2016 · 1 revision

// ViewController.h file

  1. import
@interface ViewController : UIViewController

@end ...............................

// ViewController.m file

  1. import "ViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {



UILabel *myLabel = UILabel alloc] initWithFrame: CGRectMake (50,50,200,50)];

  /*
   // CGRect labelLocation = CGRectMake(100, 100, 200, 100);
    CGRect labelLocation = CGRectMake((self.view.frame.size.width/2), (self.view.frame.size.height/2), 200, 50); // to put the label in center
    UILabel *myLabel = UILabel alloc] initWithFrame:labelLocation];
  */
  myLabel.text = @"Wecome to our Home";
textFieldName.font = [UIFont];
  myLabel.textColor = [UIColor]; // text color
  myLabel.backgroundColor = [UIColor];
  [self.view]; // self is main view
  
  
}


- (void)didReceiveMemoryWarning {
  [super];
  // Dispose of any resources that can be recreated.
}


@end
garbageUILabel alloc] initWithFrame:labelLocation];
  */
  myLabel.text = @"Wecome to our Home";
textFieldName.font = [UIFont];
  myLabel.textColor = [UIColor]; // text color
  myLabel.backgroundColor = [UIColor];
  [self.view]; // self is main view
  
  
} - (void)didReceiveMemoryWarning {
  [super];
  // Dispose of any resources that can be recreated.
} @end garbageUILabel alloc] initWithFrame: CGRectMake (50,50,200,50)];
}


- (void)didReceiveMemoryWarning {
  [super];
  // Dispose of any resources that can be recreated.
}


@end
garbage</a>UILabel alloc] initWithFrame:labelLocation];
  */
  myLabel.text = @"Wecome to our Home";

textFieldName.font = [UIFont];



}

- (void)didReceiveMemoryWarning {

  [super];
  // Dispose of any resources that can be recreated.

}

@end

Clone this wiki locally