Created
September 17, 2012 00:38
-
-
Save mathonsunday/3734988 to your computer and use it in GitHub Desktop.
viewcontroller.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.m | |
| // LayerFun | |
| // | |
| // Created by Veronica on 9/16/12. | |
| // Copyright (c) 2012 Veronica Ray. All rights reserved. | |
| // | |
| #import "ViewController.h" | |
| #import <QuartzCore/QuartzCore.h> | |
| @interface ViewController () | |
| @end | |
| @implementation ViewController | |
| - (void)viewDidLoad | |
| { | |
| self.view.layer.backgroundColor = [UIColor orangeColor].CGColor; | |
| self.view.layer.cornerRadius = 20.0; | |
| self.view.layer.frame = CGRectInset(self.view.layer.frame, 20, 20); | |
| CALayer *sublayer = [CALayer layer]; | |
| sublayer.backgroundColor = [UIColor blueColor].CGColor; | |
| sublayer.shadowOffset = CGSizeMake(0, 3); | |
| sublayer.shadowRadius = 5.0; | |
| sublayer.shadowColor = [UIColor blackColor].CGColor; | |
| sublayer.shadowOpacity = 0.8; | |
| sublayer.frame = CGRectMake(30, 30, 128, 192); | |
| sublayer.borderColor = [UIColor blackColor].CGColor; | |
| sublayer.borderWidth = 2.0; | |
| sublayer.cornerRadius = 10.0; | |
| [self.view.layer addSublayer:sublayer]; | |
| CALayer *imageLayer = [CALayer layer]; | |
| imageLayer.frame = sublayer.bounds; | |
| imageLayer.cornerRadius = 10.0; | |
| imageLayer.contents = (id) [UIImage imageNamed:@"flower.jpg"].CGImage; | |
| imageLayer.masksToBounds = YES; | |
| [sublayer addSublayer:imageLayer]; | |
| } | |
| - (void)viewDidUnload | |
| { | |
| [super viewDidUnload]; | |
| // Release any retained subviews of the main view. | |
| } | |
| - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | |
| { | |
| if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { | |
| return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); | |
| } else { | |
| return YES; | |
| } | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hmmm