diff --git a/ios/standard_controls/image_view/animate_an_imageview/AppDelegate.cs b/ios/standard_controls/image_view/animate_an_imageview/AppDelegate.cs new file mode 100644 index 0000000..2fcc532 --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/AppDelegate.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Foundation; +using UIKit; + +namespace MapView { + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register ("AppDelegate")] + public partial class AppDelegate : UIApplicationDelegate { + // class-level declarations + UIWindow window; + UINavigationController navigationController; + UIViewController viewController; + + // + // This method is invoked when the application has loaded and is ready to run. In this + // method you should instantiate the window, load the UI into it and then make the window + // visible. + // + // You have 17 seconds to return from this method, or iOS will terminate your application. + // + public override bool FinishedLaunching (UIApplication app, NSDictionary options) + { + // create a new window instance based on the screen size + window = new UIWindow (UIScreen.MainScreen.Bounds); + + viewController = new ImageViewController(); + + navigationController = new UINavigationController(); + navigationController.PushViewController (viewController, false); + + // If you have defined a view, add it here: + window.AddSubview (navigationController.View); + + // make the window visible + window.MakeKeyAndVisible (); + + return true; + } + } +} + diff --git a/ios/standard_controls/image_view/animate_an_imageview/ImageView.csproj b/ios/standard_controls/image_view/animate_an_imageview/ImageView.csproj new file mode 100644 index 0000000..f7c3ffd --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/ImageView.csproj @@ -0,0 +1,90 @@ + + + + Debug + iPhoneSimulator + 8.0.30703 + 2.0 + {9785D147-C90E-47FD-A1A0-CBD233E708BB} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + MapView + MapView + Xamarin.iOS + v1.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG; + prompt + 4 + false + true + true + None + + + + + none + false + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG; + prompt + 4 + false + iPhone Developer + true + true + + + ARMv7 + + + none + false + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + ARMv7, ARM64 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ios/standard_controls/image_view/animate_an_imageview/ImageView.sln b/ios/standard_controls/image_view/animate_an_imageview/ImageView.sln new file mode 100644 index 0000000..1949003 --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/ImageView.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageView", "ImageView.csproj", "{9785D147-C90E-47FD-A1A0-CBD233E708BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|iPhoneSimulator = Release|iPhoneSimulator + Debug|iPhone = Debug|iPhone + Release|iPhone = Release|iPhone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhone.ActiveCfg = Debug|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhone.Build.0 = Debug|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhone.ActiveCfg = Release|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhone.Build.0 = Release|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = ImageView.csproj + EndGlobalSection +EndGlobal diff --git a/ios/standard_controls/image_view/animate_an_imageview/ImageViewController.cs b/ios/standard_controls/image_view/animate_an_imageview/ImageViewController.cs new file mode 100644 index 0000000..3b454e2 --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/ImageViewController.cs @@ -0,0 +1,31 @@ +using CoreGraphics; +using UIKit; + +namespace MapView { + + public class ImageViewController : UIViewController { + + UIImageView animatedCircleImage; + + public override void ViewDidLoad () + { + base.ViewDidLoad (); + Title = "Animated ImageView"; + View.BackgroundColor = UIColor.White; + + // an animating image + animatedCircleImage = new UIImageView(); + animatedCircleImage.AnimationImages = new UIImage[] { + UIImage.FromBundle ("Spinning Circle_1.png") + , UIImage.FromBundle ("Spinning Circle_2.png") + , UIImage.FromBundle ("Spinning Circle_3.png") + , UIImage.FromBundle ("Spinning Circle_4.png") + } ; + animatedCircleImage.AnimationRepeatCount = 0; + animatedCircleImage.AnimationDuration = .5; + animatedCircleImage.Frame = new CGRect(110, 80, 100, 100); + View.AddSubview(animatedCircleImage); + animatedCircleImage.StartAnimating (); + } + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/animate_an_imageview/Info.plist b/ios/standard_controls/image_view/animate_an_imageview/Info.plist new file mode 100644 index 0000000..0cf949c --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/Info.plist @@ -0,0 +1,23 @@ + + + + + CFBundleIdentifier + com.xamarin.recipe.imageview + UIDeviceFamily + + 1 + 2 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + MinimumOSVersion + 8.3 + XSLaunchImageAssets + Resources/Images.xcassets/LaunchImage.launchimage + + diff --git a/ios/standard_controls/image_view/animate_an_imageview/Main.cs b/ios/standard_controls/image_view/animate_an_imageview/Main.cs new file mode 100644 index 0000000..704b711 --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/Main.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Foundation; +using UIKit; + +namespace MapView { + public class Application { + // This is the main entry point of the application. + static void Main (string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main (args, null, "AppDelegate"); + } + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/animate_an_imageview/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json b/ios/standard_controls/image_view/animate_an_imageview/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..44c8e2e --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,7 @@ +{ + "images": [], + "info": { + "version": 1, + "author": "xcode" + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_1.png b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_1.png new file mode 100755 index 0000000..e1ee46e Binary files /dev/null and b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_1.png differ diff --git a/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_2.png b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_2.png new file mode 100755 index 0000000..6cb8cc3 Binary files /dev/null and b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_2.png differ diff --git a/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_3.png b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_3.png new file mode 100755 index 0000000..c68de63 Binary files /dev/null and b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_3.png differ diff --git a/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_4.png b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_4.png new file mode 100755 index 0000000..f439a4d Binary files /dev/null and b/ios/standard_controls/image_view/animate_an_imageview/Spinning Circle_4.png differ diff --git a/ios/standard_controls/image_view/animate_an_imageview/readme.md b/ios/standard_controls/image_view/animate_an_imageview/readme.md new file mode 100644 index 0000000..c3cfa6f --- /dev/null +++ b/ios/standard_controls/image_view/animate_an_imageview/readme.md @@ -0,0 +1,48 @@ +id:{2690BBD5-0ACB-DDA3-7808-CBB0094165F8} +title:Animate an ImageView +brief:This recipe shows how to animate a UIImageView with an array of image frames +samplecode:[Animate_an_ImageView](https://github.com/xamarin/recipes/tree/master/ios/standard_controls/image_view/animate_an_imageview) +article:[Load an Image](/recipes/ios/standard_controls/image_view/load_an_image) +sdk:[UIImageView Class Reference](http://developer.apple.com/library/ios/#documentation/uikit/reference/UIImage_Class/Reference/Reference.html) + + + + +# Recipe + +To display an image: + +- Add all the image frames to your Xamarin.iOS project and ensure the Build Action is set to Content. +- Create a UIImageView: + + +``` +var imageView = new UIImageView (); +animatedCircleImage.Frame = new RectangleF(110, 20, 100, 100); +``` + +- Create an array of the image frames and assign it to AnimationImages: + + +``` +animatedCircleImage.AnimationImages = new UIImage[] { + UIImage.FromBundle ("Spinning Circle_1.png") + , UIImage.FromBundle ("Spinning Circle_2.png") + , UIImage.FromBundle ("Spinning Circle_3.png") + , UIImage.FromBundle ("Spinning Circle_4.png") +}; +``` + +- Set the animation properties and start animating: + + +``` +animatedCircleImage.AnimationRepeatCount = 0; +animatedCircleImage.AnimationDuration = .5; +animatedCircleImage.StartAnimating(); +``` + +The sample code shows the circle animating (difficult to demonstrate in a +screenshot): + + [ ![](Images/ImageViewAnim1.png)](Images/ImageViewAnim1.png) diff --git a/ios/standard_controls/image_view/load_an_image/AppDelegate.cs b/ios/standard_controls/image_view/load_an_image/AppDelegate.cs new file mode 100644 index 0000000..2fcc532 --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/AppDelegate.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Foundation; +using UIKit; + +namespace MapView { + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register ("AppDelegate")] + public partial class AppDelegate : UIApplicationDelegate { + // class-level declarations + UIWindow window; + UINavigationController navigationController; + UIViewController viewController; + + // + // This method is invoked when the application has loaded and is ready to run. In this + // method you should instantiate the window, load the UI into it and then make the window + // visible. + // + // You have 17 seconds to return from this method, or iOS will terminate your application. + // + public override bool FinishedLaunching (UIApplication app, NSDictionary options) + { + // create a new window instance based on the screen size + window = new UIWindow (UIScreen.MainScreen.Bounds); + + viewController = new ImageViewController(); + + navigationController = new UINavigationController(); + navigationController.PushViewController (viewController, false); + + // If you have defined a view, add it here: + window.AddSubview (navigationController.View); + + // make the window visible + window.MakeKeyAndVisible (); + + return true; + } + } +} + diff --git a/ios/standard_controls/image_view/load_an_image/ImageView.csproj b/ios/standard_controls/image_view/load_an_image/ImageView.csproj new file mode 100644 index 0000000..702ba6a --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/ImageView.csproj @@ -0,0 +1,87 @@ + + + + Debug + iPhoneSimulator + 8.0.30703 + 2.0 + {9785D147-C90E-47FD-A1A0-CBD233E708BB} + {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + MapView + MapView + Xamarin.iOS + v1.0 + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG; + prompt + 4 + false + true + true + None + + + + + none + false + bin\iPhoneSimulator\Release + prompt + 4 + false + None + + + true + full + false + bin\iPhone\Debug + DEBUG; + prompt + 4 + false + iPhone Developer + true + true + + + ARMv7 + + + none + false + bin\iPhone\Release + prompt + 4 + false + iPhone Developer + ARMv7, ARM64 + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ios/standard_controls/image_view/load_an_image/ImageView.sln b/ios/standard_controls/image_view/load_an_image/ImageView.sln new file mode 100644 index 0000000..1949003 --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/ImageView.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ImageView", "ImageView.csproj", "{9785D147-C90E-47FD-A1A0-CBD233E708BB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|iPhoneSimulator = Debug|iPhoneSimulator + Release|iPhoneSimulator = Release|iPhoneSimulator + Debug|iPhone = Debug|iPhone + Release|iPhone = Release|iPhone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhone.ActiveCfg = Debug|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhone.Build.0 = Debug|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhone.ActiveCfg = Release|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhone.Build.0 = Release|iPhone + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {9785D147-C90E-47FD-A1A0-CBD233E708BB}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + EndGlobalSection + GlobalSection(MonoDevelopProperties) = preSolution + StartupItem = ImageView.csproj + EndGlobalSection +EndGlobal diff --git a/ios/standard_controls/image_view/load_an_image/ImageViewController.cs b/ios/standard_controls/image_view/load_an_image/ImageViewController.cs new file mode 100644 index 0000000..8ea9efb --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/ImageViewController.cs @@ -0,0 +1,22 @@ +using CoreGraphics; +using UIKit; + +namespace MapView { + + public class ImageViewController : UIViewController { + + UIImageView imageView; + + public override void ViewDidLoad () + { + base.ViewDidLoad (); + Title = "ImageView"; + View.BackgroundColor = UIColor.White; + + // a simple image + imageView = new UIImageView (UIImage.FromBundle ("MonkeySFO.png")); // Build Action:Content + imageView.Frame = new CGRect (10, 80, imageView.Image.CGImage.Width, imageView.Image.CGImage.Height); + View.AddSubview (imageView); + } + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/load_an_image/Info.plist b/ios/standard_controls/image_view/load_an_image/Info.plist new file mode 100644 index 0000000..586b2ee --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/Info.plist @@ -0,0 +1,23 @@ + + + + + CFBundleIdentifier + com.xamarin.recipe.mapview + UIDeviceFamily + + 1 + 2 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + MinimumOSVersion + 8.3 + XSLaunchImageAssets + Resources/Images.xcassets/LaunchImage.launchimage + + diff --git a/ios/standard_controls/image_view/load_an_image/Main.cs b/ios/standard_controls/image_view/load_an_image/Main.cs new file mode 100644 index 0000000..704b711 --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/Main.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +using Foundation; +using UIKit; + +namespace MapView { + public class Application { + // This is the main entry point of the application. + static void Main (string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main (args, null, "AppDelegate"); + } + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/load_an_image/MonkeySFO.png b/ios/standard_controls/image_view/load_an_image/MonkeySFO.png new file mode 100644 index 0000000..4eadb26 Binary files /dev/null and b/ios/standard_controls/image_view/load_an_image/MonkeySFO.png differ diff --git a/ios/standard_controls/image_view/load_an_image/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json b/ios/standard_controls/image_view/load_an_image/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000..44c8e2e --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/Resources/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,7 @@ +{ + "images": [], + "info": { + "version": 1, + "author": "xcode" + } +} \ No newline at end of file diff --git a/ios/standard_controls/image_view/load_an_image/readme.md b/ios/standard_controls/image_view/load_an_image/readme.md new file mode 100644 index 0000000..e57a93f --- /dev/null +++ b/ios/standard_controls/image_view/load_an_image/readme.md @@ -0,0 +1,3 @@ +This is the sample code for the load an image iOS recipe on Xamarin.com. + +[See the recipe](http://developer.xamarin.com/recipes/ios/standard_controls/image_view/load_an_image/)