我想检查一下我UILabel是否感动了.但我还需要更多.文字被触动了吗?现在我只有在UILabel使用这个触摸框架时才会得到true/false :
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
if (CGRectContainsPoint([self.currentLetter frame], [touch locationInView:self.view]))
{
NSLog(@"HIT!");
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法检查这个?一旦我触摸到信件外面的某个地方,UILabel我就会想要归还.
我想知道实际黑色渲染的"文字像素"何时被触及.
谢谢!
我使用的特定字体遇到了一些麻烦.它是为学校制作的,因此A和Å的高度不同.我认为这会给我的UIButton带来麻烦.我试图解决它,但似乎无法做到正确.这是我上次尝试过的:
[self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button1.font"];
[self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button2.font"];
[self setValue:[UIFont fontWithName:@"fontname" size:220] forKeyPath:@"button3.font"];
[button1 setTitle:@"A" forState:UIControlStateNormal];
[button2 setTitle:@"Å" forState:UIControlStateNormal];
[button3 setTitle:@"Å" forState:UIControlStateNormal];
[button2 setBackgroundColor:[UIColor blackColor]];
[button2 setFrame:CGRectMake(button2.frame.origin.x, button2.frame.origin.y, button2.frame.size.width, button2.frame.size.height+100)];
[button2.titleLabel setFrame:CGRectMake(button2.frame.origin.x, button2.frame.origin.y, button2.frame.size.width, button2.frame.size.height)];
button2.contentVerticalAlignment = UIControlContentVerticalAlignmentBottom;
Run Code Online (Sandbox Code Playgroud)
这是结果:

如您所见,Å未正确显示.我怎样才能解决这个问题?
谢谢!
最好的问候,Joakim