I am working on custom keyboard for iphone 6 and 6Plus. I have develop logic for shift key active - inactive or 123 and abc key . but i want to also display custom symbol like apple keyboard shown. please check in image .
currently i am able to change uppercase to lowercase and 123 to abc but how can i set this special character. NOTE:- I searched a lot demo on github but i am not able to see special character in any custom keyboard.
Here is my logic for uppercase and ABC-123 Button.
-(void)UpparCase:(UIButton*)sender // To make caps or small letter
{
sender.selected=!sender.selected;
if(sender.selected)
{
if(isPortrait)
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"upparActive.png"] forState:UIControlStateNormal];
}
else
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_selctd_land.png"] forState:UIControlStateNormal];
}
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
NSString *uppercaseString = [[key currentTitle] uppercaseString];
[key setTitle:uppercaseString forState:UIControlStateNormal];
[key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside];
}
}
else
{
if(isPortrait)
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"UpperCase.png"] forState:UIControlStateNormal];
}
else
{
[self.ObjKeyLayout.btnCapKey setBackgroundImage:[UIImage imageNamed:@"Uppar_land.png"] forState:UIControlStateNormal];
}
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
NSString *uppercaseString = [[key currentTitle] lowercaseString];
[key setTitle:uppercaseString forState:UIControlStateNormal];
[key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside];
}
}
}
- (IBAction)action123:(UIButton*)sender // To set 123 and ABC
{
sender.selected=!sender.selected;
if(sender.selected)
{
[self.ObjKeyLayout.btn123Key setTitle:@"ABC" forState:UIControlStateNormal];
int i=0;
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
[key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i",i,(int)self.ObjKeyLayout.ArryCharKey.count);
if(isPortrait)
{
NSLog(@"\n\n123isSelected\nI-%i\tArrayCharKey.Count:-%i\nArraySpecialImageKey.Count-%i\n",i,(int)self.ObjKeyLayout.ArryCharKey.count,(int)arrspecialImageKey.count);
[key setBackgroundImage:[UIImage imageNamed:[arrspecialImageKey objectAtIndex:i]] forState:UIControlStateNormal];
}
else{
[key setBackgroundImage:[UIImage imageNamed:[arrSpecialIpad objectAtIndex:i]] forState:UIControlStateNormal];
}
[key setTitle:[NumKey objectAtIndex:i] forState:UIControlStateNormal];
[key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside];
i++;
}
}
else
{
[self.ObjKeyLayout.btn123Key setTitle:@"123" forState:UIControlStateNormal];
int i=0;
for(UIButton *key in self.ObjKeyLayout.ArryCharKey)
{
[key setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
if(isPortrait)
{
[key setBackgroundImage:[UIImage imageNamed:[arrKeyImages objectAtIndex:i]] forState:UIControlStateNormal];
}
else
{
[key setBackgroundImage:[UIImage imageNamed:[keyIpad objectAtIndex:i]] forState:UIControlStateNormal];
}
;
NSString *uppercaseString = [arrAlphabet objectAtIndex:i];
[key setTitle:uppercaseString forState:UIControlStateNormal];
[key addTarget:self action:@selector(pressKey:) forControlEvents:UIControlEventTouchUpInside];
i++;
// is123selected=NO;
}
}
}
You take two array of it, one for
alphabetical
and other fornumerical
Now in
NumKey
:and
arrAlphabet
:IBOutlet in keyBoard the
123
orABC
.Adding the event as programmatically as below.
Method to change
123
toABC
orABC
to123
output:
I have set my problem with this way because i set images of keys also .