I have a CGFloat
a
and need a CGFloat
b
, inverted from a.
If a
is 0, I need b
to be 100. If a
is 1, I need b
to be 99 ans so on.
The only solution I came up with right now is a function like the following:
func turn(_ a: CGFloat) -> CGFloat {
switch a {
case 0:
return 100
case 1:
return 99
case 2:
return 98
case 3:
return 97
case 4:
return 96
case 5:
return 95
case 6:
return 94
case 7:
return 93
case 8:
return 92
case 9:
return 91
case 10:
return 90
But a) is that insane to write for 100 Floats, and b), I need it for an animation and I receive a
in UITableView.offset
Floats, so the steps are with x decimal places and therefore I want b
to be in decimal steps as well (to have the animation smooth).
Any ideas? Help is very appreciated.
It's simply like this.
Or Simply