Questions tagged [cgfloat]

A CGFloat is the basic CoreGraphics type for all floating-point values in the Cocoa and Cocoa Touch UI frameworks.

A CGFloat is the basic CoreGraphics type for all floating-point values in the Cocoa and Cocoa Touch UI frameworks.

CGFloat is defined in the CGGeometry Reference of CoreGraphics, which defines structures for geometric primitives and functions that operate on them. Depending on your platform, a CGFloat is either 32 or 64 bits.

Use this tag when asking questions on CGFloat value types themselves, or CoreGraphics functions which use them.

207 questions
0
votes
1 answer

create a loop to space 2 different objects on a uiviewcontroller

My code below does exactly what I am looking for the problem is it just does this in a uibtton. I would like to do the same thing with 2 uitextfields and 2 uilabels. So textfield to uilabel to textfield to uilabel. I assume you would just have to…
user12274342
0
votes
1 answer

iOS: Can't get first item value from Range

I have a Range with float numbers. I need to get the first and the last elements of the range. With Range everything works fine. However when I try to get values from float range I get error "Ambiguous reference to member 'first'". How do I get…
Swifless
  • 87
  • 10
0
votes
2 answers

Accessing a method with multiple paramaters in a Swift extension

I have a method to normalise some values into a usable range (e.g. from 123-987 to 0-1). I want to create a reusable CGFloat exension of this. The method accepts three parameters and returns a CGFloat as per the signature below. How can this be made…
user1162328
0
votes
1 answer

What are the differences between CGRect options?

Typically when creating a frame for a view I use CGRect where the parameters accepts CGFloat, Double or Int. They all create a rectangle with coordinates and dimensions specified as a CGFloat, Int or Double (summarized from Apple Doc), but does it…
0
votes
1 answer

Why this function stop working as soon as I add hit boxes?

I'm trying to crate a car game where you move the car from left to right by touching the screen but as soon as I set "physics definition -> body type" and the car reach the far left or the far right of the screen, this movement function stop…
0
votes
1 answer

KVO binding a CGFloat on SCNNode

I'm trying to bind the position of a node - in this case, my pointOfView node - to a text field on macOS (but I guess it would be the same on iOS) I can bind (via .bind or Storyboard) e.g. scnView.pointOfView.camera.fieldOfView. But I can't bind…
Morten J
  • 814
  • 10
  • 21
0
votes
1 answer

No 'clamp' candidates produce the expected contextual result type 'CGFloat'

I explicitly cast the type between them, but the error is still there var destX:CGFloat = 5.0 func clamp(value: CGFloat, min: CGFloat, max: CGFloat) -> CGFloat { if value > max { return max } else if value < min { return min } return…
Dakata
  • 1,227
  • 2
  • 14
  • 33
0
votes
1 answer

Conversion from Float to CGFloat in Swift

I was converting Float => CGFloat and it gave me following result. Why It comes as "0.349999994039536" after conversion but works fine with Double => CGFloat? let float: Float = 0.35 let cgFloat = CGFloat(float) print(cgFloat) //…
Anirudha Mahale
  • 2,526
  • 3
  • 37
  • 57
0
votes
2 answers

Get first number of type CGFloat

I have following numbers in CGFloat 375.0 637.0 995.0 I need to get the first number in CGFloat data type. For example the result for #1 must be 3.0, for #2 must be 6.0 and #3 must be 9.0 I tried the following let width:CGFloat = 375.0 //…
Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207
0
votes
1 answer

CGFloat MinimumValue vs CurrentValue

I created a custom slider with a uiview class ... everything works fine but I just have a problem ... in my view controller implements the Custom Slider class this way Main ViewController #pragma mark SMALL STATS -(KPStatsSlider *)statsSlider { …
kAiN
  • 2,559
  • 1
  • 26
  • 54
0
votes
0 answers

Missing Arguments for parameters swift

I'm fairly new to swift and I'm creating a grapple hook mechanic and I'm trying to draw a line between the hook and the player when the screen is tapped, but I keep coming up with Missing Argument for parameters in call which I don't know what to…
Darin Wilson
  • 169
  • 1
  • 2
  • 9
0
votes
3 answers

How to get CGFloat/CGSize based on String length?

I have a UIView, which acts as a container and the width of this container needs to change dynamically based on the longest String. So I want to get CGFloat/CGSize based on String length, is it still possible ? The method which seems most helpful is…
Maja
  • 59
  • 1
  • 11
0
votes
0 answers

Objective C Passing CGFloat value between two classes

I have a small problem .. For convenience and to make you understand better how to share the collection View: Collectionview 1 has the customized segment control function (it has a custom UICollectionView custom class) Collectionview 2 contains the…
kAiN
  • 2,559
  • 1
  • 26
  • 54
0
votes
1 answer

Loop - invoke 'stride' with CGFloat

My code: for i:CGFloat in 0.stride(through: 100, by: spaceBetweenMarkers) Error: Cannot invoke 'stride' with an argument list of type '(through: CGFloat, by: CGFloat)' How can I use for loop by using a CGFloat value? I am using Swift 3. I want…
cole
  • 3,147
  • 3
  • 15
  • 28
0
votes
1 answer

Binary operator > error

Im working on a game, in simulator works everything perfectly. But when I try to archive the project, I get an error on the line: if !shouldDetectScoreCollision && ballClearHeight.native > basketballHoopHeight { error: binary operator > cannot…
lukas28277
  • 97
  • 1
  • 15