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
2
votes
2 answers

How to implement Static CGRect and CGFloat

I'm looking on the net but I can not find a clear answer ..          In your opinion what is the best way to make these functions static? CGRect ScreenRect = [[UIScreen mainScreen] bounds]; CGFloat screenwidth = screenRect.size.width; CGFloat…
kAiN
  • 2,559
  • 1
  • 26
  • 54
2
votes
1 answer

Formatting float to show only 5 figures

I have a float number that could be 3.553 or 34.535 or 353.6436 I want it to be no more than 5 figures, before or after the dot, for example, for the first number I wrote it has to be 3.5530, for the second 34.535 as is and for the third 353.64. How…
ytpm
  • 4,962
  • 6
  • 56
  • 113
2
votes
2 answers

"'CGFloat' is not convertible to 'Double'" error in Swift (iOS)

I'm trying to cut an image into 9 pieces in Swift. I'm getting this error: 'CGFloat' is not convertible to 'Double' I get this error when I put i or j in the two variables. Below is part of the code used for cutting the image. for i in 1...3 …
1
vote
3 answers

Problems assigning incremented values to CGPointMake

I'm trying to use the following code to move through pages of a Pdf using webView. float Y = pdfNavigateController.webView.center.y + gY; [pdfNavigateController.webView.scrollView setContentOffset:CGPointMake(0,Y)]; The value gY is also a float…
user616076
  • 3,907
  • 8
  • 38
  • 64
1
vote
3 answers

Is CGFloat both a class and not?

Here's some instance variables in a header file from an iphone game develpment book: CGFloat *point; int count; CGFloat vectorScale; Now I'm absolutaley confused. What's that asterisk before the point ivar? Is CGFLoat a class as well as it's not?
Mikayil Abdullayev
  • 12,117
  • 26
  • 122
  • 206
1
vote
1 answer

Is CGFloat more accurate than Double?

Double & CGFloat both print the same value to the console (#2), but only the Double is issued the warning (#1): (#1) - The warning (#2) - Printing each to the console DOUBLE = 9.223372036854776e+18 CGFLOAT = 9.223372036854776e+18 Many articles…
xct789
  • 46
  • 5
1
vote
1 answer

Use slider to manipulate anchors constrained by a multiplier in swift

I want to use a slider to make pic imageview smaller. Right now its in its max size. The slider should be able to make it smaller. When I use the slider the pic does decrease but I cant increase it, I can only decrease it. This is a pic of what I am…
user12418101
1
vote
1 answer

ios objective-c const CGFloat *

when I am calling setLineDash:(nullable const CGFloat *) count:(NSInteger) phase:(CGFloat) method by passing @[@1.0,@2.0] as (nullable const CGFloat *) UIBezierPath *path = [self drawLine:start ended:ended]; [path setLineDash:@[@1.0, @2.0] count:2…
Jin
  • 53
  • 5
1
vote
0 answers

Swift - SKCameraNode jitters when it zooms and moves

I have created an SKCameraNode which is is able to move around and look at a to-scale version of the solar system. I am having an issue when the camera zooms in and moves around as shown here: https://gfycat.com/HighScarceHorsemouse This is the…
samster
  • 142
  • 1
  • 2
  • 9
1
vote
1 answer

Read CGFloat from Anchor Constraints

I created an UIView and then added the Anchor constraints but I have a problem when I want to read the values ... In this case as you see, I created an NSLayoutConstraint property to get the Anchor Width of my uiview ... I then created a CGFloat…
kAiN
  • 2,559
  • 1
  • 26
  • 54
1
vote
1 answer

CGFloat variable returns 0.0

When I try this: let progress: CGFloat = CGFloat(2 / 3) print(progress) The console returns 0 but the result is 0,66666666667, not 0.... Why is that happening? When I try: let progress: CGFloat = CGFloat(10 / 3) print(progress) It returns 3.0,…
Glatteisen
  • 163
  • 1
  • 3
  • 11
1
vote
3 answers

How to convert a CGFloat to an unsigned integer

I am trying to get a string using a CGFloat, something like this.. helpMessage = [NSString stringWithFormat:@"The unsigned integer value is %i", (unsigned int)myCGFloat]; This does not want to work. Given a CGFloat value of -2 I am getting 0 for in…
user278859
  • 10,379
  • 12
  • 51
  • 74
1
vote
3 answers

Aligning floats with two decimals by the point

I have a bunch of UILabels inside a vertical UIStackView. The stack is making all labels with the same width and height. Each label has a float in it, like this: But this is ugly aesthetically. I want to align the numbers by the point. Like…
Duck
  • 34,902
  • 47
  • 248
  • 470
1
vote
1 answer

Iphone development: UIColor / CGColor components comparison

I've got some internal codes for colors in my application, so I created a function that, given a color, returns the code. I'm having problems as it just doesn't work and return always "01" for every color else than the red, which returns the proper…
w4nderlust
  • 1,057
  • 2
  • 12
  • 22
1
vote
3 answers

CGFloat in Swift 2.0

After updating Swift to 2.0 I need to fix my code. Automatic correction doesn't work. func getValueForKey(key: String) -> CGFloat { var inch = "" if screenSize.height == 480 { // iPhone 4, 4s and below inch =…
J A S K I E R
  • 1,976
  • 3
  • 24
  • 42