I suggest using xGEKKOx template for iOS which adds native UI functionality
http://forum.thegamecreators.com/?m=forum_view&t=200691&b=44. Therefore i won't mix it up with details of adding UI graphics layer
UntitledViewController.h @interface methods declaration
-(void) makeLabel:(int)tag:(float)xLocation:(float)yLocation:(NSString*)initWithText;
-(void) setLabelString:(int)tag:(NSString*)setText;
UntitledViewController.h @methods listing
-(void) makeLabel:(int)tag:(float)xLocation:(float)yLocation:(NSString*)initWithText;
{
//Create label placeholder (x,y,width,height)
UILabel* textLabel = [ [UILabel alloc ] initWithFrame:CGRectMake(xLocation, yLocation, 256.0, 20.0) ];
textLabel.textColor = [UIColor whiteColor];
//Define object tag
textLabel.tag=tag;
//Set text properties
textLabel.textAlignment = UITextAlignmentLeft;
textLabel.backgroundColor = [UIColor clearColor];
textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:(20.0)];
textLabel.shadowColor = [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.55];
textLabel.shadowOffset = CGSizeMake(0.5, 1.0);
[appDelegate.viewController.view addSubview:textLabel];
textLabel.text = [NSString stringWithFormat:@"%@",initWithText];
[textLabel release];
}
-(void) setLabelString:(int)tag:(NSString*)setText;
{
//identify textLabel
UILabel *myTextLabel = (UILabel *)[appDelegate.viewController.view viewWithTag:tag];
//Set label text
myTextLabel.text = [NSString stringWithFormat:@"%@",setText];
}
and finally, template.cpp
//define global variables for text processing
char buffer[64]="";
NSString *textString;
//in APP:BEGIN section
[VC makeLabel:1:100:100:@"Frames per second: "];
[VC makeLabel:2:100:120:@""];
//in APP:LOOP section
sprintf(buffer,"%.4f",agk::ScreenFPS());
textString = [NSString stringWithUTF8String: buffer];
[VC setLabelString:2:textString];
Output can be seen attached, simulator view
The power: you are free to use any system font or include your own one
The weakness: a. text label will always be on top of any agk object (say, depth -1) b.Using anything else on top of OpenGL ES view can affect performance
Not responsible for any typos nor liable for any risks