Set UiView background image like apple default style - iphone

I'm new on Cocoa OBJC and iPhone dev.
Where to find the default background that apple uses everywhere (like the one on the iphone's default setting app) ?
It's possible to set the image from interface builder or you have to set by line code?
Thanks

To expand on Carl's answer: if you create a UITableView in the grouped style, either via Interface Builder or using the -initWithFrame:style: method with UITableViewStyleGrouped, you'll get that background by default. Before iOS 6, if you wanted to apply it to another view, you could set that view's backgroundColor to [UIColor groupTableViewBackgroundColor]; since then, that method has been deprecated and you need to create the color yourself.

That's just the default background of a UITableView. If you make a UITableView, you'll get the background.

Related

Xcode custom UI objects

I am writing an application with xcode and I'm wondering if it is possible for me to customize the apperance of some of the UI objects as I don't think the current UI objects suite my application.
You can customise almost everything.
The Button - use your own images as backgrounds
TableView - images, custom cell content,
Navigation bar - look at the UIAppearance methods, you can again set any image as the background, or set a tint colour
Text field - this is kind of invisible except for the text, so you can give it a clear background and put it on top of anything you like
Slider - you can set custom images for the track and thumb.
You can make custom classes of UIView or even UIControl to build up an entire new-looking UI system for yourself. If you don't want such radical changes, you can simply modify some properties of the various UI elements you have in UIKit, like backgroundColor, alpha etc.

UISwitch customization?

Is possible to add images to an UISwitch background,like when the state is ON (be one background) and when the state is OFF (another background image)?
To change the background color (not image) all you have to do is below. This changes the off color for all UISwitch controls in realm.
[[UISwitch appearance] setTintColor:[UIColor brownColor]];//Off Color
_locationSwitch.onTintColor = [UIColor orangeColor];//On Color
If you want to use image, use the following cool hack of using the segmented control.
https://stackoverflow.com/a/5088099/1705353
If you want to write a lot of code, you can write your own control. Valeriy Van pointed to: https://github.com/homick/iPhone-Snippets/tree/master/General
Also another resource is: http://www.raywenderlich.com/23424/photoshop-for-developers-creating-a-custom-uiswitch with code at: http://cdn2.raywenderlich.com/wp-content/uploads/2012/10/CustomSwitchResources.zip
I would like to suggest you to follow Custom UISwitch & App Store approval to have a better idea, which is suggesting you to create a custom switch control.
You can recreate a custom UISwitch by subclassing UIControl. By doing this you can have full control over what the switch looks like. You can look take a look at SevenSwitch. A custom UISwitch replacement I've created. The on/off colors can be customized to your liking.
https://github.com/bvogelzang/SevenSwitch

Customise top bar of an iPhone application

Is it possible to customise the top bar of an iPhone application (not a website)? If so, how can I change the background colour to orange?
If you are talking about the very top bar (with the wifi-strength etc) then it's impossible following the AppStore-rules. You can change it to black only.
It's however possible with various jailbreak-tools, but then you can't publish your app to app store.
So, I'm guessing here you could be talking about a UINavigationBar or a UIToolBar, but that doesn't really matter because yes, you can change the colour of either.
In Interface Builder, select the UINavigationBar (or UIToolBar) and under properties look at "tint". This will be set to "default" initially. You can then pick any colour (even orange!) as the tint colour, and there you go!
You can do so by using the tintColor property of the navigation bar.
I have implemented and checked it. its working.
self.navigationController.navigationBar.tintColor=[UIColor orangeColor];
hAPPY cODING...

Making large toolbars like the iPod app

I am trying to create a toolbar programatically (rather than via IB) very similar to the toolbar featured in the iPhone app:
Currently I've been experimenting with the UIToolbar class, but I'm not sure how (and if?) you can make the toolbar buttons centrally aligned and large like that in the iPod app.
Additionally, regardless of size, the gradient/reflection artwork never correctly respects the size and is stuck as if the object is the default smaller size.
If this cannot be done with a standard UIToolbar, I guess I need to create my own view. In this case, can the reflection/gradient be created programmatically or will it require some clever alpha tranparency Photoshopped artwork?
The best thing you can do is:
create MyToolbar.h and MyToolbar.m : MyToolbar can be inherited from UIToobar
create an empty xib named MyToolbar.xib
In Interface Builder, add a new UIToolBar with "IB->Tools->Library"
With "IB->Tools->Inspector", change the class identity to "MyToolbar"
Now, you can customize your toolbar with IB or with xCode as you want.

How can I get the pinstripe background to show?

I'd like to use the pinstripe background that shows up in the Settings app and many other iPhone apps behind table views. Is is already included in some graphics library? How can I make it show up in a UIView or UITableView?
Pinstripe http://img.skitch.com/20090630-p783xugab8i9c7x2c63t3ped52.jpg
myView.backgroundColor = [UIColor groupTableViewBackgroundColor];
Just to stick with convention though, don't apply this background unless you're using tableviews that scroll as this type of background is semiotical to tableview scrolls.
You just have to use the "grouped" style on your table view.
As of iOS 6.0, this doesn't work anymore.