You can just use [UIColor clearColor] whenever you want to set something with a fill transparent inObjective C.
You can also do this in Interface builder by selecting the object and opening the colors window. Then adjust the alpha value with the slider at the bottom.
This works for all sorts of UI elements – buttons, textfields etc.
[label setBackgroundColor:[UIColor clearColor]];
Just a quick tip for creating a globally accessible bunch of constants for your iOS project. In AS3 I would use a class with a public static variable but in Objective C you can use constants or definitions and there are probably several other ways to do it.
To use constants globally:
- Define a new Objective C class which extends NSObject for example called ProjectConstants
- Above the implementation line in its header (ProjectConstants.h) file add this:
extern NSString * const PAGE_TITLE;
- In the implementation (ProjectConstants.m) file add:
NSString * const PAGE_TITLE = @"My Page Title";
- Access it globally by importing the ProjectConstants.h and then you can use PAGE_TITLE anywhere in the project:
NSString *pgTitle = PAGE_TITLE;
myLabel.text = pgTitle;
Another quicker way is to use definitions in your implementation of your .m file such as:
#define PAGE_TITLE @"Title"
The disadvantage of that is you can’t compare strings using pointer comparison i.e.
(myString == MyConstant) but you can still use
[myString isEqualToString:MyConstant] but its not as easy to read, and apparently not that fast either.
Baldscone was involved in completely re-designing the GUI of Stampfeet’s iPhone App to meet new customer demands and improve the apps look for Apples Retina display. You can check out more details on the app itself at stampfeet.com or at Apple’s App Store.
Download it now and get Stamping!