Transparent image overlay over below view - objective-c

I am pretty new to iOS and had a question regarding subview and their behaviour. I am trying to present a modal screen to the user upon login of a basic info screenshot. It has a bunch of tet bubbles that i want to display on top of the user login page so the user can get info on what the different options on the screen mean. Its like a transparent view on top of the screen behind it giving help texts overlays. What is the best way to do this? Currently i have a class for this overlay and i push a view in that class. but i cannot get the view below to show once i display the image overlay on top. Can anyone tell me how to do this?

This code should set an image inside of an imageview and by setting UserInteractionEnabled to NO will allow you to click content beneath the image.
UIImageView *iview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"thanks.png"]];
[iview setFrame:CGRectMake(5,5, iview.frame.size.width, iview.frame.size.height)];
[iview setUserInteractionEnabled:NO];
[self.view addSubview:iview];

Related

How does a UIAlertView determine the vertical and horizontal center of the view it's within?

I'd like to use this same solution with my UIView to get the same result.
I have a UIView with a UIScrollView. These are embedded in a UINavigationController.
A customer adds an item to their basket and I would like to give them a confirmation message. Right now a little basket UIBarButtonItem updates a title within to show the number of items. This is fine but not every user/customer will notice this.
I don't really like the style of a UIAlertView for this situation. So I'm going to add my own UIView and style it how I want to.
I'm trying to figure out how to get the UIView to show up in the center of the window. Whether the customer is using an iPhone4 or iPhone5.
UIView code:
UIView *confirmationPopup = [[UIView alloc] initWithFrame:CGRectMake(10, 200, 300, 100)];
[confirmationPopup setBackgroundColor:[UIColor redColor]];
// confirmationPopup.center = [confirmationPopup.superview convertPoint:confirmationPopup.superview.center fromView:confirmationPopup.superview.superview];
[[[self navigationController] view] addSubview:confirmationPopup];
The popup view is centered horizontally automatically but not vertically. I've tried to play around with the line you can see I've commented out but it doesn't center the UIView in the center of the window. It appears to be centering it inside the NavBar
Would appreciate some solutions.
Don't hard-code; use auto layout. You might be helped by my custom class for this purpose, an imitation alert view substitute that you can configure however you like. It takes advantage of iOS 7 custom presentation view transitions. (Of course in iOS 8 there will be even more support for this kind of thing, i.e. UIPresentationController.)

set both backIndicatorImage and backIndicatorTransitionMaskImage on backbarbutton in IOS7 didnot show particular image

I searched all the topics about backbarbutton custom, but seems failed to find answers about my problem on backbarbutton.
To keep the property called interactivePopGestureRecognizer of UINavigationController, using leftBarButton to replace backBarButton is not a valid solution. But I want to custom the backbarbutton with a image, so I use the following code in my controller ViewDidLoad:
UIBarButtonItem * btnBack = [[UIBarButtonItem alloc]init];
btnBack.title = #"";
self.navigationController.navigationBar.backIndicatorImage = [UIImage imageNamed:#"backBtn"];
self.navigationController.navigationBar.backIndicatorTransitionMaskImage = [UIImage imageNamed:#"backBtn"];
self.navigationItem.backBarButtonItem = btnBack;
when I run my project, it shows just a blue rectangle in the place where backBarButton always show.
But the original image just like the system barbutton that called reply.
However, it has a different effect, just change to the image named "Drinks" which is a black image that show a glass of juice.
after run my project the place where always show backBarButton show a blue image just like "Drinks".
what happend! How can I custom my backBarButton with the giving image named backBtn.png, is there anyone can help me? Thanks in advance! For image submit has been reject, I discrible my problem in words.
The Image has be transparent where there should be nothing to be drawn. It should be opaque where the content of the image will be drawn. At least that worked for me. The final color will be tinted by the navigationbar's tintColor anyway.

Button above image with zoom objective c

I need to show an image, and above it some buttons that correspond to certain clickable areas of the image, the problem is that the image has zoom, and when i zoom the image, the buttons do not stay in the same place as the picture. The solution was to use the class ImageScrolView, used in the example of Apple PhotoScroller. The button appears exactly in the right place, regardless of zoom.
Just like the example, i use a ScrollView to display multiple images, these images are shown by class ImageScrollView.
This class declares one UIView in the .H file, but in the implementation file, the method that displays the image, convert the UIView into a UIImageView
imageView = [[UIImageView alloc] initWithImage: image];
then create my button and add to the imageView.
amazon = [UIButton buttonWithType: UIButtonTypeRoundedRect];
amazonia.frame = CGRectMake (92,240,109,142);
[amazon addTarget: self action: # selector (selectState :) forControlEvents: UIControlEventTouchUpInside];
[imageView addSubview: amazon];
My problem is that the button does not respond to button events, it appears in the right place and everything, but does not respond to button events.
Any ideas? Ideias on how to implement those clickable areas on the image are welcome too.
make sure to set imageView.userInteractionEnabled = YES!
Hope that helps.

Rotating UITabBarController Icon

I have an UITabBar in my application. One of the tab bar icons looks like a loading symbol. When the user presses the loading button I want the icon to spin/rotate until the loading is done. Should I use UIImageView to animate or something else? How should I make this happen?
Jacos, unfortunately you cannot do that with the UITabBarController and manipulate the tabBarController's tabBar properties. My best bet would be that you use a UIToolBar and assign a black color and make it appear like a tabBar and have buttons added in them as a subView so that they look like tabBarItems.
Its much more customizable, and you can even provide a scrolling experience and add more buttons to it.
I know this question is 4 years old but I had the same problem and managed to fix it by reading the tutorial in here:
https://medium.com/#werry_paxman/bring-your-uitabbar-to-life-animating-uitabbaritem-images-with-swift-and-coregraphics-d3be75eb8d4d#.bjfpbdnut
The main point is to get the view for desired UITabBarItem and the get the UIImageView from it in viewDidLoad:
UIView *plusView = self.tabBar.subviews[1];
self.plusImageView = plusView.subviews.firstObject;
self.plusImageView.contentMode = UIViewContentModeCenter;
Then in didSelectItem method you can do this:
[UIView animateWithDuration:0.4 animations:^{
[self.plusImageView setTransform:CGAffineTransformMakeRotation(M_PI/4)];
}];
My code only rotate the image view for 45 degrees but you can change as you wish.
I guess you could change the UITabBarItem's icon on a timer, but that seems pretty kludgey. You would have to pre-render each frame of your "loading" icon rather than rotate an ImageView.
Another hackey solution would be to add your ImageView to the UIWindow and move it on top of the TabBarController's TabBar (adding it to the TabBar itself is asking for trouble).
You shouldn't try to animate the actual UIImageView within the UITabBarController. I would take this approach:
Set the image for the relevant tab to nil or a blank image.
Create a UIActivityIndicatorView and add it over the tab bar. Position it over the correct tab.
[self.tabBarController.tabBar addSubview:activityIndicatorView];
When your loading task has completed, restore the normal image to the tab and remove the activityIndicator from the tab bar.

Present UIView modally that nots full screen

I have a view 200 x 150 px which i would like to present on the tap of a button. If i use addSubview: then the view shows up in the correct position, but i can still tap other buttons on the superview, which is behaviour i don't want.
If i use presentModalViewController then the view takes up the whole screen, which is what i don't want either... this happens even if i set wantsFullScreenLayout to NO.
How can i present the view so that the user can only interact with controls on the presented view?
Thanks
Make the view the size of the screen (taking the status bar into account). That view should have a translucent background color (or clear). Have the 200x150 view be on the bottom of that view to have the appearance of a UIActionSheet, where the background dims and the user cannot interact with other elements on the screen.
Then, you can use presentModalViewController to present the view.
Addition
In the view controller's .m file, define awakeFromNib:
-(void)awakeFromNib
{
self.view.backgroundColor = [UIColor clearColor];
}