pratik
pratik

Reputation: 4479

iPhone + UIControls

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

Upvotes: 1

Views: 506

Answers (3)

Casebash
Casebash

Reputation: 118742

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.

Upvotes: 3

Henrik P. Hessel
Henrik P. Hessel

Reputation: 36617

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

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];

Upvotes: 1

raaz
raaz

Reputation: 12490

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

Upvotes: 1

Related Questions