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
1
vote
1 answer

Using iPhone/Objective C CGFloats: Is 0.1 okay, or should it be 0.1f?

When using an iPhone Objective C method that accepts CGFloats, e.g. [UIColor colorWithRed:green:blue:], is it important to append a f to constant arguments to specifiy them explicitly as floats, e.g. should I always type 0.1f rather than 0.1 in such…
MrMage
  • 7,282
  • 2
  • 41
  • 71
1
vote
1 answer

Does NSInteger allow for decimal places?

I need to have someone type in a value say "40" and then the app converts this to anther value by dividing by 7.5. at the moment i've done: NSString *pCO2 = _pCO2.text; float thepCO2 = [pCO2 floatValue]; NSInteger newpCO2 =…
LaythT
  • 23
  • 4
1
vote
1 answer

Storing floats in the app delegate

I store some floats in my app delegate, then synthesise it in the .m of the app delegate. Now when I come to use that float in one view controller I do this: del = [[UIApplication sharedApplication] delegate]; CGFloat PUEresult =…
dev6546
  • 1,412
  • 7
  • 21
  • 40
0
votes
2 answers

CGFloat getting modified went sent to viewController

This is really strange. I am getting a CGFloat value from my view and sending it over to my viewController which will pass it along to my audio engine. However, the CGFloat gets modified somehow between the view and viewController. Totally…
olynoise
  • 2,016
  • 2
  • 19
  • 32
0
votes
2 answers

Why NSString floatvalue return 0 for "NaN"?

Why i dont get NaN as result? 0 is wrong. Maybe compiler settings? CGFloat fValue = [@"NaN" floatValue]; // fValue is 0 double ddd = [@"NaN" doubleValue]; // also 0` Edit: Strange, in swift this works and returns nan: let fValue = Float ("NaN") let…
Udo
  • 43
  • 6
0
votes
0 answers

Swift CGFloat Rounding Issue

I have a really baffling issue with rounding of CGFloat (and Float which is the same). When I run the following code, the increments are not always 0.1 but rather I receive the result: plus: 0.6 plus: 0.7 plus: 0.7999999999999999 plus:…
Pete
  • 213
  • 1
  • 13
0
votes
1 answer

CGFloat value from frame.height

I got stuck with something very stupid: cannot operate with CGFloat getting from view size. Could somebody help me and explain what am I doing wrong: Here is the code: CGFloat containedViewHeight = self.containedView_.frame.size.height; …
Bitlejuce Do
  • 163
  • 3
  • 14
0
votes
2 answers

How store a tuple for NSGradient(colorsAndLocations:) in swift

To apply a gradient to a NSView, it seems best to make a class that inherits from NSView and override the draw method that sets a path and draws the gradient. class GradientView: NSView { var startColor = NSColor.red var startPosition: CGFloat =…
0
votes
0 answers

Is it bad if idealHeight is bigger than maxHeight?

I am using capsules in my application and the size of the capsules depends on integers. I want the size of the capsule to have a maximum height of 250 so I set the maxHeight: 250 and the idealHeight: height (the height is set to CGFloat var height :…
NYBSZ37
  • 61
  • 7
0
votes
1 answer

trying to do a 360 degree rotation of a object

My swift code is attempting to do a 360 degree rotation on a image view named box. The code does rotate however because I am doing a 360 degree rotation with code self.box.transform = self.box.transform.rotated(by: CGFloat.pi * 2). Pi *2 is a 360…
user13245026
0
votes
1 answer

slider only increasing imageview size not decreasing size

My swift code code below uses a slider to increase the size of the imageview. What I would like to do is when the slider moves from less than 0.5 the imageview gets smaller. If the value of the slider is equal to or greater than 0.5 the size of the…
user13245026
0
votes
1 answer

use slider to to change width and height of NSLAYOUT constraint imageview

My swift's code goal is to use a slider to increase decrease the size of a imageview. The imageview pic should be able to increase decrease size depending on what the value of slide slider is. When the func is called the origanal constraints must be…
user13245026
0
votes
1 answer

Why people add .0 on CGFloat?

https://developer.apple.com/library/archive/referencelibrary/GettingStarted/DevelopiOSAppsSwift/ImplementingACustomControl.html#//apple_ref/doc/uid/TP40015214-CH19-SW1 In this tutorial, button.widthAnchor.constraint(equalToConstant: 44.0).isActive…
손지현
  • 61
  • 9
0
votes
1 answer

I can't get CGFloat at struct[CGFloat]

Hi I'm a collage student who made some graph that show how user sleep well. I get date from date picker, and I made function to change date to CGFloat. But I can't put CGFloat in struct. Here is my code. I'm gonna made more sleep data as number of…
확마팍씨
  • 57
  • 1
  • 4
0
votes
2 answers

'Double' is not convertible to 'CGFloat?'

My Xcode keeps giving me a Double is not convertible to CGFloat error. Thing is the error keeps moving whenever I change the code. At first it was on this line: Text("left") .frame(width: 100.0, height: 100.0, alignment: .center) where I set the…
user9651306