when I change the background of UISearchBar in iOS 7 via interface builder or even in code, and enter in search mode, scopeBar wont be visible and instead its frame will be black?
why that happens?
could someone explains or provide a solution?
here is a shot:
I searched but couldn't find any solution
what I did was using an image which was wide enough to fill seacrh bar background and scopeBar background.
thats all.
first you need to create a subclass of UISearchBar and use this class as your seachBar custom class.
then in - (id) initWithCoder:(NSCoder *)aDecoder add this call
[self setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:#"searchBarBg"]]];
Related
Here is my code. This may sound like redundant question but my scenario is different as I am not adding QLPreviewController as a subview but present as a controller.
After downloading from dropbox, I present it like-
self.pdfViewController = [[QLPreviewController alloc] init];
self.pdfViewController.delegate = self;
self.pdfViewController.dataSource = self;
[self presentViewController:self.pdfViewController animated:YES completion:nil];
and I also have QLPreviewControllerDataSource, QLPreviewControllerDelegate listed as the protocol. Besides, it is working if being run in earlier than iOS 10.0.
Please help me.
It looks like iOS 10 has changed the way that QLPreviewController is presented. On iOS 9 when I preview an image by presenting the QLPreviewController modally I see a nice zoom effect and the initial state of the preview is with a black background and the navigation and toolbar hidden. I can tap the image to make the bars visible (which changes the background to white). Tapping again toggles the state.
On iOS 10 the same code results in the white background view appearing and the zoom animation being incorrect (it seems to appear from off the bottom of the screen).
I found that implementing this practically undocumented new data source method for iOS 10 fixed the issue:
- (UIView* _Nullable)previewController:(QLPreviewController *)controller
transitionViewForPreviewItem:(id <QLPreviewItem>)item
{
return [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:MIDPhotoImageRowIndex_Image inSection:MIDPhotoSectionIndex_Image]];
}
The view I return is the same view that previewController:frameForPreviewItem:inSourceView: is using as the reference for the original content's frame (i.e. the image view in my table cell).
The documentation for this delegate method at the time of writing just says "No overview available".
Implementing that method did mean that the previewController:frameForPreviewItem:inSourceView: is now called on iOS 10. I just wish there was a way to default to the original black background without navigation bars.
What is the best way to customize the look of UIButtons in an app? I am working on an app where we programatically update UIButtons to look the way we want. Most of the buttons are created in Interface Builder and we want to execute our customizeButton-method on them in an efficient way. I only see two ways of achieving this:
Create the buttons in IB, assign them to an outlet and in code call customizeButton for each button.
Problem: way too much hazzle
Subclass UIButton, in the constructor initWithCoder: call customizeButton. Then use this class for buttons in IB.
Problem: allthough this works for buttons created in IB and requires less boilerplate code than point 1, I have read all the warnings against subclassing UIButton because of their class cluster.
Clearly there must be some better way, what is point 3?
Have a look at UIAppearance. It is available since iOS 5 and is especially for customizing the standard UI elements.
For ever class that is customizable is a class method called +appearance: and you can use it like this.
[[UIButton appearance] setBackgroundColor:[UIColor redColor]];
Every button will have now a red background color.
To get started have a look at Ray Wenderlichs Tutorial User Interface Customization in iOS 5 and/or session 114 - Customizing the Appearance of UIKit Controls of the WWDC11 videos.
I want to set an image as a setting's page's/view's background image. I have already created my Settings page and I have the image. I apply a UIImage View but I can't seem to set it as the background image in Interface builder.
Forum posts like this one:
http://forums.macrumors.com/showthread.php?t=715391
seem to imply there is a 'Layout' menu item that I can pick in IB and from there select 'Send to back'. But I can't find this anywhere in Interface Builder. Am I going nuts or has this been removed from the latest version of Xcode.
If it has, is there anyway within interafce builder to send my .png image as a background image for the page.
Thanks
...Dale
I am hoping that you are using a UIImageView as background image and inserting it into your view hierarchy. There are 2 ways you could do this -
1.From IB - Forget about 'Send to back', a simpler way to set your view hierarchy is -
here in the view hierarchy, mapView is topmost and the UIImageView is at the bottom most. IF you want to change this hierarchy all you need to do is drag the view and move them up or down. hope this is clear.
2.From Code - You can either insert it any where in your view hierarchy and push it all the way to the back with sendSubviewToBack: or you can make the UIImageView the parent view.
Another way you can use an image as a background, although it requires code, is to set the view's background colour to an image.
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *backgroundImage = [UIImage imageNamed:#"background.png"]
self.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
}
I wish there was a way to do this in Interface Builder.
I need a UIALertView, which on popping up should be transparent enough to show the background behind the alertview in a faded way and the blue color of the alert view should not appear since the background behind the alert view is black and grey in color. Changing color and putting an image to the alert view is one thing which can be seen in the links : iOS 5 black transparent UIAlertView and Changing the background color of a UIAlertView?
but I need a transparent UIAlertView. Is it possible to get one?If yes how?
Thanks for the help in advance.
If you look at Apple's documentation page for UIAlertView you'll see this note:
The UIAlertView class is intended to be used as-is and does not
support subclassing. The view hierarchy for this class is private and
must not be modified.
In other words, Apple doesn't want developers to muck around with colors or fonts or backgrounds when it comes to UIAlertView. If Apple changes the internal guts of UIAlertView in a later iOS, your app is likely to have unexpected and not-desired effects when that modified alert appears.
If you want custom UIAlertView like behavior, why not just write your own UIView that looks and behaves a lot like UIAlertView. And then you have full control over everything about how it's drawn.
As Michael said, you can't with an UIAlertView, you have to build it yourself.
You can try BlockAlertsAnd-ActionSheets, it is like a customizable UIAlerView
https://github.com/gpambrozio/BlockAlertsAnd-ActionSheets
I know it's too late but,
I'll leave this command for other developers.
.h
#interface CustomAlertView:UIAlertView {}
.m
// override
- (void)drawRect:(CGRect)rect
{
for(UIView * sub in self.subviews)
{
[sub removeFromSuperview];
}
// this removeFromSuperview will clear all thing such as background view and buttons
// do something
}
Is there a way to change the "layer" that UIImageView objects are drawn in? Whenever I add an image view to a view controller it defaults to drawing the most recently added one on top of all the others. So if I decide to add a "background" image it is now a "foreground" image and blocks everything else.
There isn't anything in the IB options or in the UIImageView class reference and I haven't been able to find anything here on SO. It's been a problem for a while and it's weird that I haven't seen anything about it before... I think it might just be my semantics coming from a delphi background.
Anyway, does anyone know about this issue / ICANHAZTEHCODEZ to fix it? Or is this just like the UIScrollView problem and poorly supported by the development environment.
This happens when I try to use the editor to arrange the subviews.
You can bring a SubView to Front or Send it background programmatically using
[self.view bringSubviewToFront:yourImageView];
and
[self.view sendSubviewToBack:yourImageView];
when self.view must be the superview of your imageView
In IB, select a UIControl and from top menu bar select Editor->arrage->send to front or back
When you use UIView's addSubview: method, it will add it to the top of the view stack resulting in what you are seeing.
There are numerous other UIView methods you can use to determine the order of subviews. E.g.:
- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;
- (void)sendSubviewToBack:(UIView *)view;
- (void)bringSubviewToFront:(UIView *)view;