4
votes

While clicking, I want the big letter like in this picture.

big letter while clicking

How can I do this for my new button 'ក'? This is the code that I create button:

consonantButton = [UIButton buttonWithType:UIButtonTypeCustom];

[consonantButton setTitle:@"ក" forState:UIControlStateNormal];
 consonantButton.titleLabel.font = [UIFont fontWithName:@"Hanuman" size:30];
consonantButton.frame = CGRectMake(242.0, 328.0, 27.0, 42.0);
[consonantButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[consonantButton setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateNormal];
//  [consonantButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
//  [consonantButton setTitleShadowColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
//  consonantButton.titleLabel.shadowOffset = CGSizeMake(0, -1);

[consonantButton setBackgroundImage:[UIImage imageNamed:@"doneButtonNormal-khmer"] forState:UIControlStateNormal];
//  [consonantButton setBackgroundImage:[UIImage imageNamed:@"doneButtonHighlighted-khmer"] forState:UIControlStateHighlighted];


[consonantButton addTarget:self action:@selector(touchConsonantButton:) forControlEvents:UIControlEventTouchUpInside];

How to make the shape like this when clicking ? what is it called ? This is the code that I did for action : - (void) touchConsonantButton:(UIButton*)sender{ // [self.target performSelector:consonantAction withObject:sender]; consonantButton.frame = CGRectMake(242.0, 310.0, 54.0, 84.0); consonantButton.titleLabel.font = [UIFont fontWithName:@"Hanuman" size:50];}

and this is the screen shot: (it doesn't disappear to default)

while clicking

1
How did you put this letter in the end? I remember I answered one of your questions yesterday. - Natan R.
before I don't add code or picture yet, so I ask 1 more time to make clear whether s.o have answer! I also ask you for giving me some code, so I ask 1 more time! Sorry that I don't edit the old and make the new one ! - user1584341
this is code I did when we click button: - (void) touchConsonantButton:(UIButton*)sender{ // [self.target performSelector:consonantAction withObject:sender]; consonantButton.frame = CGRectMake(242.0, 310.0, 54.0, 84.0); consonantButton.titleLabel.font = [UIFont fontWithName:@"Hanuman" size:50]; if (onSetTextFieldCallBack!= nil) { NSMutableString *c = (NSMutableString *)[[(UIButton *)sender titleLabel] text]; self.onSetTextFieldCallBack (c); } } - user1584341

1 Answers

0
votes

Add two targets to your button:

[consonantButton addTarget:self action:@selector(touchUpConsonantButton:) forControlEvents:UIControlEventTouchUpInside];
[consonantButton addTarget:self action:@selector(touchDownConsonantButton:) forControlEvents:UIControlEventTouchDownInside];

Now selectors are:

-(void)touchUpConsonantButton(id)sender
{
  UIButton *btnClicked = (UIButton *)sender;
  // your code here
  [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
    btnClicked.transform = CGAffineTransformMakeScale(2.0f, 2.0f);
  } completion:^(BOOL finished){
    // if you want to do something once the animation finishes, put it here
  }];
}

-(void)touchDownConsonantButton(id)sender
{
  UIButton *btnDown = (UIButton *)sender;
   // your code here
  [UIView animateWithDuration:0.1 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
    btnDown.transform = CGAffineTransformIdentity;
  } completion:^(BOOL finished){
    // if you want to do something once the animation finishes, put it here
  }];
}