Wednesday, 15 September 2010

ios - How do I get the minimum value of two CGFloats in Swift? -



ios - How do I get the minimum value of two CGFloats in Swift? -

this question has reply here:

swift equivalent min , max macros 3 answers

i have code should homecoming minimum value of 2 cgfloat values:

var boundssize:cgsize = scrollview.bounds.size var imagesize:cgsize = imageview.bounds.size var xscale:cgfloat = boundssize.width / imagesize.width var yscale:cgfloat = boundssize.height / imagesize.height var minscale:cgfloat = min(xscale, yscale) // not work

but min not seem have equivalent in swift. how do this?

try this:

var minscale = min(xscale, yscale)

min in swift. hope helps.. :)

min variadic function. reset parameter variadic parameter. developer site:

a variadic parameter accepts 0 or more values of specified type. utilize variadic parameter specify parameter can passed varying number of input values when function called. write variadic parameters inserting 3 period characters (...) after parameter’s type name.

for more info. see this.

ios swift cgfloat

No comments:

Post a Comment