I have been searching thru the web but cant find a confirmed answer.
There are ways like removing the subview within the searchbar.subviews but is that allowed?
If not then, aside from changing the tintColor of SearchBar, or use a textfield instead,
is there a way that wont break apple's rule and still being able to customize the background of searchBar?
Thanks!
You are not breaking apple's rules if you are not conflicting with private API's.
I worked on a shipping app that made the background of the search bar transparent. There were no problems with this.
A solution I've seen used a lot (albeit only on toolbars and navigation bars, so I'm not 100% sure it'll work the same way): subclass UISearchBar and override its -drawRect:, drawing your own background image within the view's bounds.
Related
In our native iPad app, we need a few customizations to be done to the tab bar namely:
We want the height of the tab bar to be 54px,
The highlight color of the tab bar icons when selected needs to be yellow
There has to be a slight shadow at the top edge of the tab bar.
Apple's documentation states that UITabBarController is not meant to be subclassed.
Please advise what would be the best way to achieve the above customization if I cannot subclass UITabBarController.
Thanks.
You can subclass it, just apple discourages it because someone is bound to screw it up/change the functionality drastically. If you're just theming it and it doesn't look ugly, things should be fine.
If they do reject it, you can just go to the default UITabBar and ship with that.
You may also want to look at Three20
I think your best option would be to use a custom solution based on UIViewController.
I did write an iOS 7+ compatible simple UITabBar+UITabBarController replacement, you could use it as a starting point. It can support any number of tabs and that uses Auto Layout to build it's view hierarchy. Check out NGTabBar.
I am doing a lot of researching lately about how to get a different looking with nice effects UITabBar on my iPhone app, but unfortunately I am only finding things on how to replace background color etc.
Well, I've checked out this app called Momento which is pretty cool and presents a very slick tabBar:
So there are a couple of elements here I would like to ask you guys if you could help me by giving me the right directions on how to get a similar effect :)
Arrow above items: as you can see this app has this animated arrow that runs above the selected item with a very smooth animation.
Selected Stated of the item's image is not that blue-ish default one neither the default state which displays in a different shade of brown and gray version.
nice Items separators with beveled vertical lines.
different background image for the tabBar
different height for the tabBar
At this point after some research I am able to set the height and background image by subclassing UITabBarController but I'm still not sure on how to accomplish the other items specially the first one related to the nice arrow effect.
How do I do this? Please clarify what can or can't be done by subclassing the UITabBarController and specially if can be done in Interface Builder.
There's a project on github called BCTabBarController that aims to mimic the tab bar used in Twitter for iPhone. It's got some of the things you're looking for, and should give a great starting point.
Both of these are good answers, but both libraries have problems: BCTabBarController doesn't know how to create the "blue" highlighted version of a tab bar icon; and iDevRecipies doesn't send events to child viewcontrollers nor resize the navigation bar on rotate.
Be warned: custom nav bars are a lot of trial-and-error debugging (as I have found).
Simply use a UIView with TabBar width and height.Add custom background image and custom buttons on the view.Set the fileowner of the view as AppDelegate.Now you can simply connect the IBActions with the buttons.The Custom view can be placed over the tabbar by addSubView to the TabBar controller's view.You can switch between viewcontrollers by using the setSelectedIndex method of tableviewcontroller in the button action.
My iPhone application uses the camera to take pictures, which I suspect is somewhat memory-intensive. The app uses a custom background image for the view of its UINavigationController, and after taking a few pictures, the background goes all white. Any ideas on what I can do to stop this?
Check to see if -didReceiveMemoryWarning is being called in any of your viewControllers. If it's a low memory problem, that's probably the culprit.
Expanding on Ben Gottlieb's post, is it really necessary for you to have the custom background image? That by itself is a big memory waste; I shutter (eh, camera pun) to think of combining the two without releasing the picture before redisplaying the tableView.
Unfortunately, the project was very specific about having a background image, so I had to retain it despite the memory waste.
My work-around was to unload the background once you've entered the photos-view, and then reload it before you leave. Not the most beautiful solution, but it works really well.
I had exactly the same issue, and resolved it by subclassing UINavigationController.
Then in the viewDidLoad method I simply create my background (ImageView) and add it to the view.
If your UINavigationController is created from a nib, just give it your custom class name in IB. I had to do that as I also have a custom navigationbar, which you can only set in IB.
I'm building an iPhone application and like most I am trying to implement a UIScrollView with a UIPageControl, however I am coming across a very quirky behavior, which I assume may be a bug. Hopefully one of you has seen this before because it is driving me nuts.
Basically, the page control works fine, everything is hooked up and works normally on all accounts EXCEPT, with certain placements of the UIPageControl within the UIView, the UIPageControl will cease to render.
I'll just take screenshots of the XIB window to help illustrate... here's a placement that works perfectly fine:
http://www.jasconi.us/prob1.png
The UIPageControl is placed physically above the UIScrollView. Works great, everything is visible and working.
The next two DO NOT work:
http://www.jasconi.us/prob2.png
http://www.jasconi.us/prob3.png
The first one is simply placed below the scroll view. Doesn't render at all.
The second one is placed above the scroll view without technically being inside of it. Also doesn't render.
What the hell is up with this? I've tried using
[[self view] bringSubviewToFront:pageControl];
...to no avail.
Any ideas?
OK I found the answer to this, it's a little six degrees of Kevin Bacon.
This isn't actually a software bug, but a XIB quirk, for some reason the lower placement of the page control in combination with the default settings for autosize and anchor seem to jettison the control into outer space.
If you turn off all auto-scaling and auto-sizing and auto-anchoring and all that other crap, the controls appear exactly as you expected. The fact that it appears reliably when placed above the ScrollView is an oddity.
shrug.
Hope this helps future iPhone initiates.
Did you check to make sure that numberOfPages is not 0?
If you set a breakpoint can you see that pageControl is not nil?
I was still encountering this exact same problem, even after trying everyone's posted answers. My issue ended up being a little more "DOH":
I was using UIPageControl at the bottom of a modal FormSheet, however, I forgot to set the size of the view as Form Sheet in the xib. This caused my page control to be off the screen and never visible.
Moral: set view size (Full, Form, Page, etc) in your xib on the base view.
This will sound like a real no brainer, but I got caught out by it.
By default, UIPageControl expects to be on a dark background. IE: The dots are light gray, and white for the current page.
I used UIPageControl on it's own with no scrollview to change the time range of a graph I was rendering with drawRect:
Long story short, the graph background was white, so the page controller worked, I just couldn't see it. The solution was putting the graph itself in a subview, and making the parent that contained the page control have a dark background.
Is it possible?
I have a UINavigationBar that I'd like to have an 'edit' button next to the 'back' button. From what I've read you can only have one or the other, which makes no sense as they are separate properties of the navigationItem object(backBarButtonItem and leftBarButtonItem).
I'm assuming you have to somehow insert a custom UIView into the UINavigationBar. I'm looking into this option and if no better solution is given then I'll outline this method.
The short answer is:
Yes, you have to add your own UIButton views (or other UIControl subclasses) to the navigation controller, yourself. So, ignore the custom *ButtonItem properties and roll it yourself.
A little more involved answer is:
Apple makes it very easy to follow their HIG guidelines, but you're on your own if you want to break them or customize. In this case, only one button is allowed, because the actual hit region is bigger than the size of the displayed button--much easier to hit from a usability standpoint.
Extraneous:
btw, there is a subtle distinction between left/rightBarButtonItem and backBarButtonItem. left/right is specified on the current UIViewController. However back is specified by the previous UIViewController.
Using a custom view is indeed your only option here. The UINavigationBar is not terribly flexible. What you will need to do is create a UIView that contains UIButtons. Be sure you realize that if you use a custom view, you gain none of the automatic behaviors of the backBarButtonItem; you have to create your own IBActions, and the graphics for the buttons as well.
On a related note, I'm not sure this is the best idea. It's usually wise to stick to Apple's UI guidelines; is there no where else you can put the edit button? The right side of the bar, for example?
While #Kelvin's answer works for pre iOS 5, if you're using iOS 5+ there is now a leftBarButtonItems array property. Note that you also must set leftItemsSupplementBackButton to true.