Posts

Showing posts from April, 2013

iOS: Adding rounded corners in a layer

Image
    CALayer *layer = roundedFrameView. layer ;     layer. cornerRadius = 8.0f ;     layer. borderColor = [[ UIColor colorWithRed : 0.89 green : 0.89 blue : 0.98 alpha : 1 ] CGColor ];     layer. borderWidth = 0.8 ; The RGB color above will render a light gray color which is ideal for a rounded frame. Check out my screen shot below. You notice the frame where it covers the string "The Item is list as "On Sale"..." is being framed.

iOS: Using CGColorRef to use an RGB color to add drop shadow

    //CGColorRef pixelColor = [[UIColor redColor] CGColor];     // UIColor* color = [UIColor colorWithCGColor:pixelColor];       CGColorRef*  aqua = [UIColor colorWithRed:0.521569 green:0.768627 blue:0.254902 alpha:1] CGColor];                 layer. masksToBounds = NO ;     layer. shadowRadius = 1.0f ;     layer. shadowOpacity = 0.5f ;     layer. shadowColor = aqua; //  ( __bridge   CGColorRef )([ UIColor   grayColor ]); // use bridge when it's not a CGColorRef type     layer. shadowOffset = CGSizeMake ( 4.0f , 5.0f );     layer. shouldRasterize = YES ;     layer. borderWidth = 0.8 ;

iOS: Adding a drop shadow in an image

You can just modify the x,y and width and height values inside the CGRectMake to make adjustments for your object's relative coordinates and you can also adjust as well the radius, opacity and offset of the shadow. Make sure your self.contentView is the view where your image is shown, and take note that your image must be added after the shadow, not before the shadow so it'll be behind the image. By adding an image, just do after the code above somewhat like, self.imageView =  [[ UIImageView alloc ] initWithImage :[ UIImage   imageNamed : @"CellImageTest.png" ]]; [ self . contentView addSubview : self . imageView ];

iOS: Forcing orientation in your view controller (iOS 6 and iOS < 6)

Got this trouble on forcing the app to be in a a landscape mode. Let say, you have a standard orientation of a Portrait but at first force the view controller to be in landscape where the button is located in the left side. So I have this code that you can try, play, and modify. See below, // //  MainViewController.h @interface MainViewController : UIViewController <UIWebViewDelegate> @end // MainViewController.m #import "MainViewController.h" @implementation UINavigationController ( autorotation ) // >= iOS 6 - ( BOOL ) shouldAutorotate {         UIInterfaceOrientation interfaceOrientation = [ UIApplication sharedApplication ] .statusBarOrientation;     NSLog ( @ "intefaceorientation: %d" , interfaceOrientation ) ;     [ self.topViewController shouldAutorotate ] ;     return YES ;     } // >= iOS 6 - ( NSUInteger ) supportedInterfaceOrientations