1.項目中引用QuartzCore.framework
2.在AppDelegate.m檔案中引用QuartzCore.h庫
#import <QuartzCore/QuartzCore.h>
3.在application: didFinishLaunchingWithOptions:方法的return YES語句前添加以下代碼
UIApplication *app = [UIApplication sharedApplication];[app setStatusBarStyle: UIStatusBarStyleBlackOpaque];self.window.rootViewController.view.layer.cornerRadius = 5;self.window.rootViewController.view.layer.masksToBounds = YES;
4. 整體代碼如下:
#import "AppDelegate.h"#import <QuartzCore/QuartzCore.h>@implementation Corner_TestAppDelegate@synthesize window=_window;@synthesize viewController=_viewController;- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window.rootViewController = self.viewController; [self.window makeKeyAndVisible]; UIApplication *app = [UIApplication sharedApplication]; [app setStatusBarStyle: UIStatusBarStyleBlackOpaque]; self.window.rootViewController.view.layer.cornerRadius = 5; self.window.rootViewController.view.layer.masksToBounds = YES; return YES;}