ios - What is CGFloat.random(min: CGFloat, max: CGFloat) of swift 2 in swift 3? -


im trying generate cgfloat random not know how done in swift 3. cgfloat.random(min: cgfloat, max: cgfloat) of swift 2 equivalent in swift 3? , can find changed swift functions swift 2 swift 3?

from https://stackoverflow.com/a/28075467/2383604 use this:

public extension cgfloat {     /// randomly returns either 1.0 or -1.0.     public static var randomsign:cgfloat {         {             return (arc4random_uniform(2) == 0) ? 1.0 : -1.0         }     }     /// returns random floating point number between 0.0 , 1.0, inclusive.     public static var random:cgfloat {         {             return cgfloat(arc4random())         }     }     /**      create random num cgfloat       - parameter min: cgfloat      - parameter max: cgfloat       - returns: cgfloat random number      */     public static func random(min: cgfloat, max: cgfloat) -> cgfloat {         return cgfloat.random * (max - min) + min     } }  cgfloat.random cgfloat.random(min: 0.1, max: 0.2) 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -