iOS Dev (12) UIView, UIImage, UILabel
저자: CSDN 대 예 형 주소:http://blog.csdn.net/prevention
AppDelegate
.h
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate: UIResponder<UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController;
@end
.m
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
- (BOOL) application: (UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
ViewController *viewController = [[ViewController alloc] initWithNibName:nil bundle:nil];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void) applicationWillResignActive: (UIApplication *)application
{
}
- (void) applicationDidEnterBackground: (UIApplication *)application
{
}
- (void) applicationWillEntreForeground: (UIApplication *)application
{
}
- (void) applicationDidBecomeActive: (UIApplication *)application
{
}
- (void) applicationWillTerminate: (UIApplication *)application
{
}
@end
ViewController
.h
#import <UIKit/UIKit.h>
@interface ViewController: UIViewController
@end
.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void) viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor redColor];
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 200, 100)];
view.backgroundColor = [UIColor colorWithRed:1.0 green:0 blue:0 alpha:0.6];
[self.view addSubView:view];
UIImage *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 210, 200, 100)];
imageView.backgroundColor = [UIColor colorWithRed:0 green:1.0 blue:0 alpha:0.6];
[self.view addSubView:imageView];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 220, 200, 100)];
label.backgroundColor = [UIColor colorWithRed:0 green:1.0 blue:1.0 alpha:0.6];
[self.view addSubView:label];
}
- (void) didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end