How to scale down a UIImage and make it crispy / sharp at the same time instead of blurry?

Merely using imageWithCGImage is not sufficient. It will scale, but the result will be blurry and suboptimal whether scaling up or down. If you want to get the aliasing right and get rid of the “jaggies” you need something like this: http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/. My working test code looks something like this, which is Trevor’s solution with … Read more

What’s the difference between Quartz Core, Core Graphics and Quartz 2D?

Quartz 2D is an API of the Core Graphics framework that implements drawing. Quartz Core is a framework that includes APIs for animation and image processing. Quartz frameworks and their APIs CoreGraphics.framework Quartz 2D API manages the graphic context and implements drawing. Quartz Services API provides low level access to the window server. This includes … Read more

iOS: what’s the fastest, most performant way to make a screenshot programmatically?

I’ve found a better method that uses the snapshot API whenever possible. I hope it helps. class func screenshot() -> UIImage { var imageSize = CGSize.zero let orientation = UIApplication.shared.statusBarOrientation if UIInterfaceOrientationIsPortrait(orientation) { imageSize = UIScreen.main.bounds.size } else { imageSize = CGSize(width: UIScreen.main.bounds.size.height, height: UIScreen.main.bounds.size.width) } UIGraphicsBeginImageContextWithOptions(imageSize, false, 0) for window in UIApplication.shared.windows { window.drawHierarchy(in: … Read more

How to draw a smooth circle with CAShapeLayer and UIBezierPath?

Who knew there are so many ways to draw a circle? TL;DR: If you want to use CAShapeLayer and still get smooth circles, you’ll need to use shouldRasterize and rasterizationScale carefully. Original Here’s your original CAShapeLayer and a diff from the drawRect version. I made a screenshot off my iPad Mini with Retina Display, then … Read more

Extracting rgb from UIColor [duplicate]

The code sample you provided should work. Try this: UIColor uicolor = [[UIColor greenColor] retain]; CGColorRef color = [uicolor CGColor]; int numComponents = CGColorGetNumberOfComponents(color); if (numComponents == 4) { const CGFloat *components = CGColorGetComponents(color); CGFloat red = components[0]; CGFloat green = components[1]; CGFloat blue = components[2]; CGFloat alpha = components[3]; } [uicolor release];

Get lighter and darker color variations for a given UIColor

Updated Use below UIColor Extension: extension UIColor { func lighter(by percentage: CGFloat = 30.0) -> UIColor? { return self.adjust(by: abs(percentage) ) } func darker(by percentage: CGFloat = 30.0) -> UIColor? { return self.adjust(by: -1 * abs(percentage) ) } func adjust(by percentage: CGFloat = 30.0) -> UIColor? { var red: CGFloat = 0, green: CGFloat = … Read more

How to Convert UIView to PDF within iOS?

Note that the following method creates just a bitmap of the view; it does not create actual typography. (void)createPDFfromUIView:(UIView*)aView saveToDocumentsWithFileName:(NSString*)aFilename { // Creates a mutable data object for updating with binary data, like a byte array NSMutableData *pdfData = [NSMutableData data]; // Points the pdf converter to the mutable data object and to the UIView … Read more

Inner shadow effect on UIView layer?

For anyone else wondering how to draw an inner shadow using Core Graphics as per Costique’s suggestion, then this is how: (on iOS adjust as needed) In your drawRect: method… CGRect bounds = [self bounds]; CGContextRef context = UIGraphicsGetCurrentContext(); CGFloat radius = 0.5f * CGRectGetHeight(bounds); // Create the “visible” path, which will be the shape … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)