You can actually design a "sample button" using Interface Builder, have all the formats done (which is nice and easy using IB), then put it at the root of the widget hierarchy. Since it is not a sub-view of any other widgets, it is not shown at run-time. Then you can use the following code to copy this button as you want, place it anywhere you want, without worrying the format:
NSData *archived = [NSKeyedArchiver archivedDataWithRootObject: button_sample];
//Initiate buttons based on a sample
UIButton* b = [NSKeyedUnarchiver unarchiveObjectWithData: archived];
//set text, change position...
...
No comments:
Post a Comment