Search This Blog

Thursday, 3 November 2011

Generate Custom Keyboard (Buttons)



Hello Friend!
Here we are going to generate custom keyboard
//Copy and paste buttongenerate void function in your .m file of your project

-(void)buttongenerate
{
int xposition=0;
int yposition=0;
for (int i = 0; i < 26; i++) 
{
UIButton *btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
  [btn setFrame:CGRectMake(xposition, yposition, 30, 30)];
[btn setTitle:@"@" forState:UIControlStateNormal];
[btn setTag:i];
  [btn addTarget:selfaction:@selector(buttonclick:)
                      forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:btn];
xposition=xposition+30;
if(i == 9 || i==19)
{
yposition=yposition+30;
xposition=0;
}
}

}



//Also copy and paste buttonclick function in your project below or above the buttongenerate function
//This function is called on the action of button clicked which is generated




-(void)buttonclick:(UIButton *)sender
{
NSLog(@"Button TAG>>%i",sender.tag);
}
Thats finish.

No comments:

Post a Comment