tags:

views:

144

answers:

3

Hello All,

It is a very generic question (not related to any application). Just my quest to know more.

While creating any iPhone application, we see that there few UIControls available in Library of Interface Builder. Using those we can create all basic application and designs, and also we can't customize those to much extent

But if we see on App Store, thousands of applications are available, where there many UIControls which are either not available in Library or might be they customized to much extent.

I want to know that:

  1. Can we use controls other than available in Library (if yes than how and from where to get that).

  2. If we can't than how do we modify (customize) the available UIControls to such an extent that they look totally different from their original primary look.

Regards, Pratik

+3  A: 

For a start, it is possible to set an image (including transparency) for most controllers. Many controller that look like different controls may actually be the same controls, just reskinned. Many controllers allow subviews - it is amazing how much can be achieved just using the table controller.

It is also worth knowing that any control you place using the GUI can also be set to a subclass where you override behaviour. Simply select the control, hit Shift-Apple i and change the class in Class Identity.

Casebash
Casebash, can you explain in more detail what is reskinned, also if I use too many image in application, there would be Memory issue ??
pratik
I think you need to provide more detail about what kind of controls you want to achieve.
Casebash
Suppose I want to customize UIPickerView than ?
pratik
UIPickerView is very easy to customize (at least the elements that spin), because you can have any number of rows and return any view you want (including images) for each element. Look for the UIPickerView tutorials to see how custom UIPickers work, but it's a lot like setting up delegate calls for a UITableView.
Kendall Helmstetter Gelner
Yep, I forgot to mention subviews
Casebash
+1  A: 

Hi pratik, take a look at the three20 library. It include custom styled button, labels and text. It should give you the general idea, how to customize your own UI elements.

Often, you don't use images like casebash mentioned, instead your drawing your elements with graphical methods.

Another possible solution is to override your

- (void)drawRect:(CGRect)rect

of your UIView

Edit:
Source Code taken from

http://stackoverflow.com/questions/1663002/custom-uibutton-for-iphone

INDEX_OFFSET = 82753; // random

UIButton *sampleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[sampleButton setFrame:CGRectMake(kLeftMargin, 10, self.view.bounds.size.width - kLeftMargin - kRightMargin, 52)];
[sampleButton setTitle:@"Button Title" forState:UIControlStateNormal];
[sampleButton setFont:[UIFont boldSystemFontOfSize:20]];
[sampleButton setTag:<INDEX>+INDEX_OFFSET];
[sampleButton setBackgroundImage:[[UIImage imageNamed:@"redButton.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
[sampleButton addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:sampleButton];
Henrik P. Hessel
Henrik, can you please explain in details what do you mean by drawing your elements graphical methods ?
pratik
pratik, I added some code. I won't pressure you, but if found any of the answers here usefull, you you should start to upvote or accept them (even if it isn't my answer :)
Henrik P. Hessel
A: 

For customised controllers you can check the Three20 Project by Joe Hewitt.

raaz