how to add the dimmed background found in UIAlertView - ios

Im making a custom dialog thats similar to UIAlertView, and was wondering if anyone had any ideas how I can emulate the dimming background as in the photo below.

I agree that you should be very careful to have a real justification for redoing something that is already there, but if you really need it, it's easy:
Create a PNG image with the same size as the targeted device's screen, with alpha. TFill the image black, and add a radial opacity gradient, so that in the center, it is relatively transparent, while towards the screen edges it'll be more opqaue. This effect is called vignetting. Maybe there even is a vignetting filter on your preferred image editor, which you could use on a completely transparent image.
This image approach also has the benefit of allowing you to use completely different effects of fading away the background.
Create a UIImageView with the vignette image, and transparent background. Add the view to your app's Window, on top of all other views, but below your alertView:
UIImageView *vignetteView = [[UIImageView alloc] initWithImage: [UIImage imageNamed:#"vignette.png"]];
vignetteView.backgroundColor = [UIColor clearColor];
vignetteView.userInteractionEnabled = YES; //this means users won't be able to touch the UI elements below
[self.view.window insertSubview: vignetteView belowSubview: myAlertView];

First off, I'd recommend that you do your best to avoid the need for a custom modal dialog. You can usually give your feedback contextually within the flow of your application's actual views.
If your app targets iOS 5 only, UIAlertView offers three new styles to allow text input, secure text input, or a user name and password combo.
If you still need a custom modal alert, and you're looking to stay consistent with the iOS look and feel, and maintain resolution independence, I'd recommend that you avoid using static graphical assets. Instead, take the (somewhat hackish) approach of subclassing UIAlertView, and adding your own controls to it. You can find examples of doing this here and here.

Related

Animated Background

I am making an app in which there are two buttons in the center. The background is there and I need the background to have an animation. With that said I mean like little raindrops constantly falling in the background. I have no clue on how to do this. My customer really, really wants this. Thanks!
Make sure the images are named in numerical order with the number at the end of the name. Then drag and drop the file of images into your Xcode folder area. Then you reference only the image name and not the number in animatedImageNamed.
You need to create an ImageView the size of the Background for each device you plan on using.
//place this in your viewDidLoad
UIImageView * background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 55)];
UIImage * image = [UIImage animatedImageNamed:#"MovingCar" duration:3.6];
background.image = image;
[self.view setBackgroundView: background];
You can change the duration to suit your needs accordingly.
You could use the UIView method animateWithDuration:animations: or one of it's variants that has a completion method to animate images from the top to the bottom of the screen. Take a look at the Xcode docs on that method, and search the web for examples.
As the other poster says, this site is for helping people with problems, not for asking others to provide you with ready-made solutions.
I could bang out some animation code for you that would create an endless stream of falling raindrops, but it would probably take me a couple of hours to get it fully working, and I'd have to charge you for it. (Plus I'm not very familiar with Swift so I'd have to do some translation from Objective-C, which is my day-to-day programming language.)

iOS map style config slide up?

iOS 7 has changed how maps are displayed by apps on the iPhone, and especially how the user configures the map.
The map is displayed like this, with an Info button.
When the user taps the Info button, the configuration screen slides up.
How do I recreate a screen overlay like this in my code? While I don't want the user to be dropping pins, I want the user to be able to switch between different map styles or open the address I'm pointing to in Apple's Maps app.
If you are trying to do a simple overlay view, then look into making an UIView slide up through UIView animations. Other than that, you would need an UISegmentedControl and related code. You would also need to blur the view and make it translucent, so look into my other question and answer on how to properly blur an UIView:How to apply blur to a UIView?
I've never looked into it, but I've heard the only easy way to do a translucent background (as in, without writing your own OpenGL code) is to create a UIToolbar instance.
I'm guessing you'd make a toolbar with no items, just treat it like UIView and add your own subviews (UITableView, etc). It is a subclass of UIView.

How to create a see through button with "blurred" background in iOS 7

I am updating my app to iOS 7 and wanted to improve the UI. I want to create a see through background like Control Center. So basically I have a button, which I would like to have a see through and "blurred" background like control center. Thanks!
There's nothing to stop you using a UIToolbar.
Create a UIView as a base view with clear background, add a UIToolbar anchored to it's edges so it fills the view and then add your other controls to your base view above the toolbar.
It'll look for example like this:
The blurring effect is not available as a public API. There are third party implementations available, such as FXBlurView, which I can recommend.
You shouldn't really be using a toolbar. It's called toolbar for a reason.
One way to go would be to take a snapshot image of your background and blur it (you can use UIImage+ImageEffects category included in Apple samples to achieve consistent effect).
You can then just crop the image to desired frame and use it as a background of your button.
Are you looking to have a 'dynamic' blur effect (like in Control Center)? It's still doable, but it makes things more complicated.
You can also create blur effects with GUPImage Framework here is a full tutorial about it iOS blur effect tutorial. The tutorial also explains why you shouldn't use toolbar for blur effect creation

Set background texture for my iphone app UIView

I am newbi to iphone apps as well as to this forum.
I want to place a background texture for my UIView that should cover the whole iPhone screen. I have controls placed on this view currently. Later on, I would like all my controls to be transparent, so user must be able to work with controls, but not see anything except its text.
Here is what I tried:
Created a UIView derived view - with simple background color, no image
Placed my controls - UIButtons, labels
Programmed all of them correctly to reflect my game logic
Now I have a change of my mind. I think its lot better to have a background texture for my view, as well as controls.
1) I tried things mentioned at: Adding A Background Image In Interface Builder
but this covers my UI controls.
2) Through Interface builder, I tried drag-dropping the texture image onto my view (which in turn, probably, created a UIImageview with background image = my texture). But that again hid every of my past work.
Then I started playing with alpha value (0.1, 0.8 etc) - it gives me some result, but I am no longer able to design my controls. Nor I am able to click (=touch) them at runtime anymore.
Please give me a method that will not disrupt my work so far (I hate redoing all the outlet wiring of my controls), but still allow me to achieve my goal.
Forgive me if I asked too silly thing, or did not search enough. This is my first question, and will be glad to try any helpful solution!
Many thanks!
How about:
self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"texture.png"]];

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