Ios Swift Adding UIImageView with a transition / effect - ios

I added multiple UIImageView to a Viewcontroller with Swift Code like that:
let imageView_pergament = UIImageView(image: UIImage(named: "pergament.png")!)
...
...
view.addSubview(imageView_pergament)
And I would like that they shows up with an transition like effect (pixel in etc.)
Can someone please help with that did not find a solution yet. Same would be good for removing / hiding them. Maybe, I just need to put a view around it?
Thanks a lot for any help.

In iOS, the easy way to perform animation as a view is added or removed is by calling animate:
https://developer.apple.com/reference/uikit/uiview/1622451-animate
One typical strategy is to add the view with alpha of 0 and animate the change of alpha to 1, thus causing the view to "fade in". However, by animating the transform you can achieve vastly more interesting effects if you wish.

Related

Insert blur layer between two existing view layers

I have a UIView with some buttons on it. What I would like to do, is add a full screen blur layer between the UIView and the buttons when the user does a long press on one of them. The visual appearance and location of the buttons shouldn't change.
What is the best way to do this? Also, if possible, I would like to avoid transfering the buttons from one view to another, as this might cause me a lot of trouble (the buttons are draggable).
You can use -[UIView insertSubview:belowSubview:] method to place blur view behind buttons.
I would suggest using Pop animation framework for animations.
As for creating blur view this looks good: https://stackoverflow.com/a/25706250/2754158
You could create a view with the blur effect, and use the method view.insertSubView(blurView, above|belowView: view)

Full customisation of UINavigationBar

I'm currently building an iOS Application for a client and have hit a pretty huge roadblock. I mean, I could write my own UINavigationBar and such but that would cause a lot of issues further down the road.
I have tried everything in my knowledge so far and have spent several hours searching for a solution (overriding the CALayer, using CoreGraphics and pretty much everything else ) and I get the same result. No matter how hard I try to remove the background of the UINavigationBar, it still shows a white background with slight translucency.
I need to have a lot of customisation on the navigation bar (I.E having a gradient going from "blackColor" to "clearColor" and I can't do that if the background of the Navigation Bar refuses to be completely transparent. I have tried copying all of the CALayers from the UINavigationBar layer to a subview I added and it just kept crashing, even when replacing the delegates and superlayer.
I really need help with this. One of the multiple effects I'm trying to achieve are below. (The blue rectangle is not the focus of the image, it's irrelevant.)
To get it completely transparent:
(UINavigationBar.appearance()).translucent = true
(UINavigationBar.appearance()).barTintColor = UIColor.clearColor()
(UINavigationBar.appearance()).backgroundColor = UIColor.clearColor()
(UINavigationBar.appearance()).setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
(UINavigationBar.appearance()).shadowImage = UIImage()
EDIT:
Using iOS 8.3 looking like this:
Or am I missing something?
You are referring to the top Navbar with the back button and Save button right? I'm just confused as to what the blue box on the image is in reference too.
Anyways, this is an extremely hacky approach but could work:
Set the UINavigationBar's alpha to 0. The Back button and Save button will probably also disappear but you could just add labels to the View Controller at the top in the exact same place. The button's should still be functional even though they are "invisible" but the user will still think they are touching them.
Again, very hacky, but you are free to play with the top part of the View then. I'm sure there's a better way to do this but I'm not near a computer with XCode at the moment and can't test it out, and this fix may not even work but I thought I'd offer up a possible temporary solution.

How to implement Circular iCarosel?

I tried all the ways by setting the respective value's but i'm unable
get below one by using iCaurosel,or is there any controller which gives same functionality
? can you help me?
You should choose iCarousel type to wheel:
self.carousel.type = iCarouselTypeWheel;
but if you mean items margin, this is not possible:
https://github.com/nicklockwood/iCarousel/issues/306
Please check following sample. this is dynamic circles (views) you can add.:)
https://github.com/mpospese/CircleLayout
Happy coding.
You can achieve the same functionality by creating the custom circular UICollectionView layout.Please visit the following link to solve this.
http://developer.xamarin.com/guides/ios/user_interface/introduction_to_collection_views/
You can do this using carousel.type = iCarouselTypeWheel and then using the carousel:valueForOption:withDefault: delegate method to adjust circle radius, number of items shown, etc.
To position the circle off-center like that, use carousel.contentOffset.
You may find that the gesture handling is a bit weird though, because the pan gesture will still be linear even though the view appears circular.

What is UITableView separatorEffect property for?

New in iOS 8 is a separatorEffect property, to which you are allowed to assign a UIVisualEffect. Has anyone figured out what this is for? I've tried it and I don't see it as having any, uh, visual effect.
I was wondering the exact same thing so I put a Github project together for anyone facing the same issue.
The basic idea is that if your tableView's backgroundView consists of a UIVisualEffectView with a blur effect, then setting the seperatorEffect to a Vibrant Effect with the same blur as the UIVisualEffectView will produce the effect we see in Notification Center where the separators seem transparent.
Something like this:
tableView.separatorEffect = UIVibrancyEffect(forBlurEffect: blurredBackgroundView.blurView.effect as UIBlurEffect)
will produce a table view like this:
Start by watching session 419 from this year's WWDC: "Advanced Graphics and Animations for iOS Apps", they explain how the new visual effect classes work.
I have a UITableViewController in my app that I use as a modal popover. The parent view controller gets blurred by a UIVisualEffectView with a UIBlurEffect, while the table view separators have a UIVibrancyEffect set as effect. On my iPhone 5, it looks like this:
This is what that same view looks like if separatorEffect is nil:
You could, of course, apply a UIBlurEffect to the separators, but that would most likely just be a waste of resources.
Note: Don't actually do what I did in this example. UIVibrancyEffect is very expensive. Just applying a UIVibrancyEffect to this table view's separators caused my app to miss the 60 FPS target on an iPhone 5.
Also note that the Reduce Transparency option under the Accessibility section in Settings.app is a thing and causes UIBlurEffects to be rendered as a solid color. Always check before instancing any UIVisualEffects. Here's some keywords for you to google: UIAccessibilityIsReduceTransparencyEnabled() and UIAccessibilityReduceTransparencyStatusDidChangeNotification
Hope I could help you.
As both answers have said, the only effect this is intended for is a vibrancy effect when the background of the table is a blur effect. The difference with and without the effect can be subtle:

Disable whole UIView

My app needs to save an image to disk. I do this in a separate thread, so the UI is still responsive, BUT, I do not want the user to add a new image until the first one is saved (about 1 second.)
At the moment, I'm disabling the 'take another picture' button and greying it out, but I'm wondering if there is a method that will disable the whole view, greying out the buttons and darkening the background, like what happens when a UIActionSheet is presented.
I've looked through the UIView docs and don't see anything like this, but it seems like such a useful pattern that is frequently used by Apple that I figured I'd ask, just in case there was such a thing.
Obviously I could do it manually, but why reinvent the wheel if its already part of the API.
TIA: John
set whatever view (main view, subview, etc.) you want to appear disabled to
view.userInteractionEnabled = NO
and also
view.alpha = 0.3f
and maybe even
view.backgroundColor = [UIColor grayColor]
to boot. These last two can be animated, b.t.w.
Present another view with the shadow and the gradient etcetera over this view thus giving it an effect of graying out with shadows. You may even create an image if you know your photoshop. Just show that image on a UIImageView over this view to be blocked. Give the image some nice translucency, shadows etc etc

Resources