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

How to get X coordinate of a word inside a NSString

I have a label with a sentence in it, that is one string. I need to get the x coordinate for a specific word in the string. So for example, if I have a sentence that says "The dog ran" inside of the sentence, I need to be able to find the x and y…
Chandler De Angelis
  • 2,646
  • 6
  • 32
  • 45
0
votes
1 answer

App subversion to float

I am getting my app's version like this: NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] And then trying to convert it to a float like this: [version floatValue] Now that all works great, but when I…
Jonathan
  • 507
  • 5
  • 15
0
votes
2 answers

What do i need to return to tableView:heightForRowAtIndexPath?

I have a view controller with several tables. I want one table to have larger cells than the others. Right now, I have: - (CGFloat *)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView !=…
GeneralMike
  • 2,951
  • 3
  • 28
  • 56
0
votes
2 answers

Using CGFloat and "memory footprint"

I was reading this and I am curious about what was meant by increasing the memory footprint. I am not an expert in any of this, by any means. I actually know very little, other than what I've come up with thinking about how systems work. If someone…
RileyE
  • 10,874
  • 13
  • 63
  • 106
0
votes
2 answers

find minimum values in CGFloat obtained in a loop

I am drawing reactangles in a loop based on the parameters that I get from the looping variable event as below : CGRectMake(cellWidth * event.xOffset,(cellHeight / MINUTES_IN_TWO_HOURS * [event minutesSinceEvent]), cellWidth,cellHeight /…
-1
votes
2 answers

What is a "(UIView) -> CGFloat"? I am trying to get a CGFloat value

extension UIScrollView { func scrollPositionY(view:UIView) -> CGFloat { if let origin = view.superview { // Get the Y position of your child view let childStartPoint = origin.convert(view.frame.origin, to: self) …
RanLearns
  • 4,086
  • 5
  • 44
  • 81
-1
votes
1 answer

A little confused about NSDecimalNumber?

there are a short code NSString *numString = @"2128.123123"; NSDecimalNumber *large = [NSDecimalNumber decimalNumberWithString:numString]; NSDecimalNumberHandler *decimalHandler = [NSDecimalNumberHandler…
-1
votes
2 answers

Change UIView frame Height and width from user input from UIText field

I am able to change height and width of UIView frame on button click by hardcoding the height and width, but i am unable change it when i get input from user in UItext field in CGFloat format. ` import UIKit class SetBorderSizeViewController:…
Ammad
  • 3
  • 3
-1
votes
1 answer

AnyObject & Cannot assign to immutable expression of type 'CGFloat'

I have two example functions. Both do exactly the same thing. The difference lies in the type of the variable "objectName". The first works. I am specific and set the type to UILabel. Obviously I can only use it with UILabel type objects and…
-1
votes
1 answer

How to invert a CGFloat in Swift 3?

I have a CGFloat a and need a CGFloat b, inverted from a. If a is 0, I need b to be 100. If a is 1, I need b to be 99 ans so on. The only solution I came up with right now is a function like the following: func turn(_ a: CGFloat) -> CGFloat { …
David Seek
  • 16,783
  • 19
  • 105
  • 136
-1
votes
1 answer

How to use max with swift3?

i am getting an error for the bellow code: var bubbleWidth:CGFloat! bubbleWidth:CGFloat = max( CGFloat(15) , bubbleWidth ) here is the error message: no candidates produce the expected contextual result type 'cgfloat!' this code was working without…
david
  • 3,310
  • 7
  • 36
  • 59
-1
votes
1 answer

Swift Random Color Generator

I am making a game where there's a grid of squares, and one is a different color (all colors are shades of turquoise). I'm using a function to generate two different random colors func generateColors() -> (main: UIColor, diff: UIColor) { let…
sw2037122
  • 63
  • 6
-1
votes
1 answer

How to Typecast in Swift?

I'm working on a custom path for UIBezierPath, and I'm getting the "Cannot assign a value of type (CGFloat) to a value of type CGFloat." I think it's because there is some issue with typecasting? How can I fix this? The warnings are popping up for…
James Yu
  • 23
  • 1
  • 5
-1
votes
1 answer

Out of scope CGFloat array

I want to use a C-style CGFloat array defined in the didMoveToView method in the touchesBegan method. I can't seem to define it as a property because it is a CGFloat array. Globals don't seem to work either. My array is defined like this: CGFloat…
-1
votes
4 answers

Convert float to float and truncate after two decimal places Objective-C

I have a float var1 = cashInHandAmount = 4.73000002 I simply want as: var2 = 4.73. I have tried like this: NSString *floatString = [NSString stringWithFormat:@"%.02f",cashInHandAmount];//it prints 4.73 [self.editcash setMaxValue:[floatString…
maddy
  • 4,001
  • 8
  • 42
  • 65
1 2 3
13
14