Skip to main content

Posts

Showing posts with the label core-graphics

UIImagePickerController, UIImage, Memory and More?

I've noticed that there are many questions about how to handle UIImage objects, especially in conjunction with UIImagePickerController and then displaying it in a view (usually a UIImageView ). Here is a collection of common questions and their answers. Feel free to edit and add your own.

Inner shadow effect on UIView layer?

I have the following CALayer: CAGradientLayer *gradient = [CAGradientLayer layer]; gradient.frame = CGRectMake(8, 57, 296, 30); gradient.cornerRadius = 3.0f; gradient.colors = [NSArray arrayWithObjects:(id)[RGB(130, 0, 140) CGColor], (id)[RGB(108, 0, 120) CGColor], nil]; [self.layer insertSublayer:gradient atIndex:0]; I'd like to add an inner shadow effect to it, but I am not quite sure how to do this. I suppose I would be required to draw in drawRect, however this would add the layer on top of other UIView objects, since it's supposed to be a bar behind some buttons, so I am at a loss as to what to do? I could add another layer, but again, not sure how to achieve the inner shadow effect (like this: http://sublimeorange.com/uploads/2009/09/innershadow.png ) Help appreciated... Source: Tips4all

NSLog with CGPoint data

I have a CGPoint called point that is being assigned a touch: UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; I want to get the x coordinate value into my console log: NSLog(@"x: %s", point.x); When I use this, log output for this is: x: (null) I have verified that point is not null when this is called using the debugger and variable watch. Any help appreciated, Thanks // :)

CGContextSetShadowWithColor not working

This code should be showing a shadow, but it isn't: CGContextRef context = UIGraphicsGetCurrentContext(); //Border CGMutablePathRef outerPath = createRoundedRectForRect(self.bounds, MENU_BUTTON_OUTER_RADIUS); CGContextSetFillColorWithColor(context, [[UIColor colorWithWhite:0 alpha:0.18] CGColor]); CGContextAddPath(context, outerPath); CGContextFillPath(context); //Button UIColor *buttonColor; if (self.type == JMenuButtonTypeBlack) { buttonColor = [UIColor colorWithWhite:0 alpha:1.0]; } else if (self.type == JMenuButtonTypeWhite) { buttonColor = [UIColor colorWithWhite:0.72 alpha:1.0]; } CGRect insideRect = rectForRectWithInset(self.bounds, 3); CGMutablePathRef innerPath = createRoundedRectForRect(insideRect, MENU_BUTTON_INNER_RADIUS); CGPoint gradientTop = CGPointMake(0, insideRect.origin.y); CGPoint gradientBottom = CGPointMake(0, insideRect.origin.y + insideRect.size.height); //Base color CGContextSaveGState(context); CGContextSetFillColorWithColor(context, [buttonColor

UIImage Resize without loss of quality

Im looking for an external library (or a method using Apple frameworks that doesn't destroy the quality) which will let me scale down images. I have tried this 'simple-image-processing-library' but it only works for black and white - I don't know how to make it work for colour images. ( http://code.google.com/p/simple-iphone-image-processing/ ) I have tried Core Graphics, UIKit, the "trevor" ( http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/ ) method - which makes EXTREMELY blurry images and really I don't know what else I can do - I can't continue programming my app without getting at least half-decent image scaling working. I think interpolation is needed to get decent results. Given the recent advances in iOS, I really hope someone can help me. This isn't a problem that only I am having, lots of other people seem to have the same problem, so if someone could solve it here, I'm sure if would appreciated by a