Chiedo un valore come questo:Come ottenere questo valore come CGFloat?
[self.layer valueForKeyPath:@"transform.rotation.z"]
po 'ho bisogno di passare ad un metodo che prende un CGFloat come parametro. Qual è il trucco del casting qui?
Chiedo un valore come questo:Come ottenere questo valore come CGFloat?
[self.layer valueForKeyPath:@"transform.rotation.z"]
po 'ho bisogno di passare ad un metodo che prende un CGFloat come parametro. Qual è il trucco del casting qui?
In Swift:
let f = view.layer.valueForKeyPath("transform.rotation.z")!.floatValue
In Objective-C:
NSNumber* n = [self.layer valueForKeyPath:@"transform.rotation.z"];
CGFloat f = [n floatValue];
Se si voleva una, in un modo più conciso linea per farlo, si può fare:
CGFloat f = [[self.layer valueForKeyPath:@"transform.rotation.z"] floatValue];