Forcing a UIImageView to Remain in Front of an Active Animation - swift

Language: Swift, IDE: Xcode for iOS development, Single View Application > View Controller...
I have 2 UIImage Views with identical images that I'm scroll-animating from left to right across the view in order to create a 'slowly-moving background' of sorts. I'd like to place other UI elements (Labels, other images, etc.) in the foreground of this repeating background animation, but find when I run the simulator the foreground image isn't seen...
Question: Is it possible to force other UI elements to stay in front of a repeating animation programmatically?
I'm not at my Mac so I can't share my code at the moment, but if you know a straight answer to the question and/or which method could best achieve this, I'm all ears!!
Thanks in advance! :)

This depends on the z-ordering of the views. Assuming you are adding all of your views then starting the animation call bringSubViewToFront on the view you are animating right before you start animating it. If you are laying things out in interface builder the Z order is based on top = farthest and bottom = closest. If you are adding view programmatically the newest view is always added in front. You can change this with insertSubview:at: and the related methods. Take a look at the documentation for UIView.

If you want z-index use:
YourImageViewName.layer.zPosition = 1
Also you could play with bringToFront method on the parent view:
self.view.bringSubviewToFront(YourImageViewName)
Hope this fix your problem.

Related

How to move other uiobjects relatevely when a new view is shown in the main view

I am developing an iPhone app,which contain a page consisting of three UISwitch. When the the UISwitch is in On state the app displays a small view below the switch. This works for all three switches. But the problem is that the small views displayed will overlaps if I switch on two switches at a time. Is there a way to shift all the other view relatevely when those views are displayed..
Thanx in advance....
This sort of problem is exactly what auto layout is good for. When you add a new object, remove and regenerate your constraints (you may only need to change a couple, depending on what it currently in place), then call layoutIfNeeded on the superview. If you do that inside an animation block, it will even animate into the new layout for you.
Its a bit late but this may be what you looking for.
CollapseClick

How to Display Custom View Modaly

I've written a small multiplayer game for the iphone. Once one of the players win, I want to display him 'You Win' image and a button so that he can play again.
How can this be done? One option is to use a segue to a new view-controller, but I think this should be shown with the game in the background. What would you suggest, as I'm pretty sure this is a common scenario for an iphone game/app.
EDIT: I ended up using both Phillip Mills's answer and Selkie's answer. Here is on How to Use UIView transitionWithView?
You can create the custom view and keep it as a separate property within your main game view controller. When someone wins, add it as a subview to the view property of the controller. It can be full screen size with transparency so that it's effectively modal, yet shows the game as background.
You can make it as a view, then show it using UIView animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations
The animation block could be sliding up, fading or whatever you want.
The other way is to add it at the beginning, but set its hidden property as YES. Change it to NO when it's needed.

How does Facebook iPhone app implement the pop-over window for notifications?

How does Facebook iPhone app (4.1) implement the pop-over window for notifications (see below for screenshot)? I thought this was only capable on the iPad. Is this a lookalike that they have custom built?
Check out this library which can implement pop over menus like facebook app: https://github.com/50pixels/FPPopover
I think it is far more complicated (and cleaner) than either of answers (guesses) so far. It is likely a completely separate view controller with it's own content view that is being added as a subview of the container view.
There are some libraries that so a similar thing, here is one for example:
https://github.com/KJoyner/SeaGlass/wiki/SGPopoverController-Documentation
http://www.facebook.com/note.php?note_id=107632999326583
https://github.com/chrismiles/CMPopTipView
My first guess would be that the "popover" is just a subview within the mainview.
First you create the subview, then hide it mySubView.hidden = TRUE; . When the user taps on the Globe button just "unhide" mySubView.hidden = FALSE; the subview with a nice 1 second animation (which will make it fade in).
I imagine that the edges with the rounded corners, subtle inner glow, and outer shadow are part of a resizable 9 part image. From there, it just about placing it on screen stretching it out and drawing the arrow at the appropriate location to line up with the bar button item.

webOS style view switching on iPhone app

I have been working with a iPhone app that I would like to have switch views like the Palm Pre does for multitasking. I know the usual way of switching views by using the black bar at the bottom of the app but the app I am working on does not lend itself to having a big black bar in the way (see attached picture #1).
I guess my question is, how do I shrink the current view (Current Location window) and show other views on the sides? (see attached picture #2) Then be able to swipe left and right to view other views. I have no idea how to do this and would be eternally grateful if someone could help me out with this.
http://www.threepixeldrift.com/images/deep-storage/webOScardapp1.jpg
http://www.threepixeldrift.com/images/deep-storage/webOScardapp2.jpg
The architecture should be similar to that of NavigationController: you have a number of ViewControllers each responsible for one card in your app. Then you have a 'super-controller' which controls these ViewControllers, by adding and removing their controlled views from the superview when necessary.
You'll need to use CoreAnimation and write the animations yourself.
i would use a UIScrollView and each card can be a small view that is shown by setting the contentoff set.

Thumbnail slider in toolbar like iPad Photos app

I would like to put thumbnails in the toolbar like the Photos app. Like the screenshot on the left:
(source: apple.com)
Is there is a built-in control to do this, or do I have to implement it from scratch?
If the answer is from scratch, any tips?
This would be a control you'd have to write yourself. I'm not what the best approach would be, but I think I'd go with subclassing a UISlider, drawing the array of images next to each other to create the track, and then using the current image as the handle.
From scratch, is the answer, unfortunately.
You create a custom view and add your array of images as subviews using UIImageView objects incrementing your x position by the the thumbnail width you've determined to use.
Then override the touch events for you custom view. Determine which image view the touch is currently over in -touchesMoved and use Core Animation to animate the current view's scale making it larger than the rest. Add the custom view to your toolbar wrapping your custom view in a UIBarButtonItem using -initWithCustomView.
Remember to enable user interaction on your custom view or you won't receive any touch events. If you need help with the code, update your question with some code specific questions.
Should anyone still need it, I made an effort of coming up with ThumbnailPickerView - a simple UI control resembling Photos.app thumbnail slider.