uiviewanimation

How to load GIF image in Swift?

僤鯓⒐⒋嵵緔 提交于 2019-11-26 21:39:40
I have a String with an URL of GIF banner which I need to put into app. My code: func showAdd(){ Request.get("http://www.kyst.no/api/?apiMode=advertisement&lang=no", { (error: NSError?, data: NSData, text: NSString?) -> () in let jsonResult: Dictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as Dictionary<String, AnyObject> var banner : NSString = jsonResult["advertisement"]!["banner"] as NSString self.addViewImage.image = UIImage.animatedImageNamed(banner, duration: 1) }) } But nothing happens. Please help. Load GIF image

How to rotate image in Swift?

孤街浪徒 提交于 2019-11-26 19:59:00
问题 I am unable to rotate the image by 90 degrees in swift. I have written below code but there is an error and doesn't compile func imageRotatedByDegrees(oldImage: UIImage, deg degrees: CGFloat) -> UIImage { //Calculate the size of the rotated view's containing box for our drawing space let rotatedViewBox: UIView = UIView(frame: CGRect(x: 0, y: 0, width: oldImage.size.width, height: oldImage.size.height)) let t: CGAffineTransform = CGAffineTransform(rotationAngle: degrees * CGFloat(M_PI / 180))

How to flip an individual UIView (without flipping the parent view)

浪子不回头ぞ 提交于 2019-11-26 19:56:59
This is an iPad project where I have a UIView with several subViews, and I am trying to animate one of this UIViews using [UIView transitionFromView:toView:duration:options:completion], but when I run this method the whole parent view gets flipped! This is the code I'm using: UIView *secondView = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 300, 300)]; [newView setBackgroundColor:[UIColor redColor]]; [UIView transitionFromView:self.firstView.view toView:secondView duration:1.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil]; Any idea on how can I flip between this

How can I pop a view from a UINavigationController and replace it with another in one operation?

时光毁灭记忆、已成空白 提交于 2019-11-26 19:24:27
I have an application where I need to remove one view from the stack of a UINavigationController and replace it with another. The situation is that the first view creates an editable item and then replaces itself with an editor for the item. When I do the obvious solution within the first view: MyEditViewController *mevc = [[MYEditViewController alloc] initWithGizmo: gizmo]; [self retain]; [self.navigationController popViewControllerAnimated: NO]; [self.navigationController pushViewController: mevc animated: YES]; [self release]; I get very strange behavior. Usually the editor view will appear

Swap rootViewController with animation?

大兔子大兔子 提交于 2019-11-26 19:07:57
问题 Im trying to swap to another root view controller with a tab bar; via app delegate, and I want to add transition animation. By default it would only show the view without any animation. let tabBar = self.instantiateViewController(storyBoard: "Main", viewControllerID: "MainTabbar") let appDelegate = UIApplication.shared.delegate as! AppDelegate appDelegate.window = UIWindow(frame: UIScreen.main.bounds) appDelegate.window?.rootViewController = tabBar appDelegate.window?.makeKeyAndVisible() That

Completion block for popViewController

和自甴很熟 提交于 2019-11-26 18:48:31
问题 When dismissing a modal view controller using dismissViewController , there is the option to provide a completion block. Is there a similar equivalent for popViewController ? The completion argument is quite handy. For instance, I can use it to hold off removing a row from a tableview until the modal is off screen, letting the user see the row animation. When returning from a pushed view controller, I would like the same opportunity. I have tried placing popViewController in an UIView

I want to use animation to imageview using UIanimationtransitioncurl right or left. Is it possible?

微笑、不失礼 提交于 2019-11-26 18:27:39
问题 I want to animate my photo gallery like the pages of the book. Is there any method with that I can use UIanimationtransitioncurl in either the left or right side? This is the code as you have suggested to me. I have done the allocation on the viewdidload method. self.title = @"TransitionsTitle"; // Create the container view which we will use for transition animation (centered horizontally). CGRect frame = CGRectMake(round((self.view.bounds.size.width - kImageWidth) / 2.0), kTopPlacement,

UIView Hide/Show with animation

元气小坏坏 提交于 2019-11-26 18:12:01
My simple goal is to fade animate hiding and showing functions. Button.hidden = YES; Simple enough. However, is it possible to have it fade out rather than just disappearing? It looks rather unprofessional that way. Nick Lockwood In iOS 4 and later, there's a way to do this just using the UIView transition method without needing to import QuartzCore. You can just say: [UIView transitionWithView:button duration:0.4 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ button.hidden = YES; } completion:NULL]; Previous Solution Michail's solution will work, but it's not actually the

Changing back button in iOS 7 disables swipe to navigate back

╄→гoц情女王★ 提交于 2019-11-26 15:37:45
I have an iOS 7 app where I am setting a custom back button like this: UIImage *backButtonImage = [UIImage imageNamed:@"back-button"]; UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; [backButton setImage:backButtonImage forState:UIControlStateNormal]; backButton.frame = CGRectMake(0, 0, 20, 20); [backButton addTarget:self action:@selector(popViewController) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *backBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; viewController.navigationItem.leftBarButtonItem = backBarButtonItem; But this

How to make UIView animation sequence repeat and autoreverse

独自空忆成欢 提交于 2019-11-26 15:19:36
问题 How to make this complex animation repeat and autoreverse? Is there any way to add options UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat to this animation sequence? [UIView animateWithDuration:1.0f animations:^{ someView.frame = someFrame1; } completion:^(BOOL finished) { [UIView animateWithDuration:0.5f animations:^{ someView.frame = someFrame2; } completion:nil]; }]; 回答1: To animation from point 1 to 2 to 3 to 2 to 1 and repeat, you can do use animateKeyframesWithDuration