I’m trying to make custom control (like UIButton) manually which can recognize user’s touch.
So, when even custom control’s superlayer is scaled, I want to know if user’s touch point is contained in custom control’s frame.
thus I need to know scaled size of custom control.
Is CALayer support this property or function?
Sorry. Previous code has faults so I have edited the code like following.
uiView1 = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)] autorelease];
uiView1.backgroundColor = [UIColor yellowColor];
uiView1.transform = CGAffineTransformScale(uiView1.transform, 2.0, 2.0);
scaledButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
scaledButton.frame = CGRectMake(100, 100, 100, 40);
[scaledButton setTitle:@"Test" forState:UIControlStateNormal];
nonscaledButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
nonscaledButton.frame = CGRectMake(100, 100, 100, 40);
[nonscaledButton setTitle:@"Test" forState:UIControlStateNormal];
[uiView1 addSubview:scaledButton];
[self.view addSubview:uiView1];
[self.view addSubview:nonscaledButton];
NSLog(@"uiButton1 width : %f, height : %f", scaledButton.frame.size.width, scaledButton.frame.size.height);
NSLog(@"uiButton1 width : %f, height : %f", scaledButton.layer.bounds.size.width, scaledButton.layer.bounds.size.height);
NSLog(@"uiButton1 width : %f, height : %f", scaledButton.realFrame(???).size.width, scaledButton.realFrame(???).size.height);
Can’t know how to get scaled size… => scaledButton (200,80)
following is running result.
/Users/nice7285/Library/Caches/appCode10/DerivedData/RealSize-e4f66643/Build/Products/Debug-iphonesimulator/RealSize.app/RealSize
Simulator session started with process 1567
2012-09-01 16:52:31.124 RealSize[1567:15d03] uiButton1 width : 100.000000, height : 40.000000
2012-09-01 16:52:31.126 RealSize[1567:15d03] uiButton1 width : 100.000000, height : 40.000000

You get CGRect after like CGAffineTransformScale like this: