How to write text on image in Objective-C (iOS)?

Draw text inside an image and return the resulting image: +(UIImage*) drawText:(NSString*) text inImage:(UIImage*) image atPoint:(CGPoint) point { UIFont *font = [UIFont boldSystemFontOfSize:12]; UIGraphicsBeginImageContext(image.size); [image drawInRect:CGRectMake(0,0,image.size.width,image.size.height)]; CGRect rect = CGRectMake(point.x, point.y, image.size.width, image.size.height); [[UIColor whiteColor] set]; [text drawInRect:CGRectIntegral(rect) withFont:font]; UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return newImage; } Usage: // note: replace “ImageUtils” with the class … Read more

Add animated Gif image in Iphone UIImageView

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds]; animatedImageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@”image1.gif”], [UIImage imageNamed:@”image2.gif”], [UIImage imageNamed:@”image3.gif”], [UIImage imageNamed:@”image4.gif”], nil]; animatedImageView.animationDuration = 1.0f; animatedImageView.animationRepeatCount = 0; [animatedImageView startAnimating]; [self.view addSubview: animatedImageView]; You can load more than one gif images. You can split your gif using the following ImageMagick command: convert +adjoin loading.gif out%d.gif

iOS – UIImageView – how to handle UIImage image orientation

If I understand, what you want to do is disregard the orientation of the UIImage? If so then you could do this: UIImage *originalImage = [… whatever …]; UIImage *imageToDisplay = [UIImage imageWithCGImage:[originalImage CGImage] scale:[originalImage scale] orientation: UIImageOrientationUp]; So you’re creating a new UIImage with the same pixel data as the original (referenced via its … Read more

How to set the opacity/alpha of a UIImage?

I just needed to do this, but thought Steven’s solution would be slow. This should hopefully use graphics HW. Create a category on UIImage: – (UIImage *)imageByApplyingAlpha:(CGFloat) alpha { UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGRect area = CGRectMake(0, 0, self.size.width, self.size.height); CGContextScaleCTM(ctx, 1, -1); CGContextTranslateCTM(ctx, 0, -area.size.height); CGContextSetBlendMode(ctx, kCGBlendModeMultiply); CGContextSetAlpha(ctx, alpha); CGContextDrawImage(ctx, area, … Read more

UIImageView pinch zoom swift

UIImageView pinch zoom with UIScrollView || image zooming ios in swift 3 and Xcode 8 letter Youtube video URL set uiscrollview Delegate in storyboard class PhotoDetailViewController: UIViewController, UIScrollViewDelegate { @IBOutlet weak var scrollView: UIScrollView! @IBOutlet weak var imgPhoto: UIImageView! override func viewDidLoad() { super.viewDidLoad() scrollView.minimumZoomScale = 1.0 scrollView.maximumZoomScale = 6.0 // scrollView.delegate = self – … Read more

How to set image in circle in swift

import UIKit class ViewController: UIViewController { @IBOutlet weak var image: UIImageView! override func viewDidLoad() { super.viewDidLoad() image.layer.borderWidth = 1 image.layer.masksToBounds = false image.layer.borderColor = UIColor.black.cgColor image.layer.cornerRadius = image.frame.height/2 image.clipsToBounds = true } If you want it on an extension import UIKit extension UIImageView { func makeRounded() { layer.borderWidth = 1 layer.masksToBounds = false layer.borderColor = … Read more

How to cancel UIView block-based animation?

You can stop all animations on a view by calling: [view.layer removeAllAnimations]; (You’ll need to import the QuartzCore framework to call methods on view.layer). If you want to stop a specific animation, not all animations, your best best bet is to use CAAnimations explicitly rather than the UIView animation helper methods, then you will have … Read more

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