I want to know how can I print CGRect attributes(frame) values on console using NSLog() method.
I tried to see properties of CGRect, like this:
NSLog(@"CGRect Value: %@", rect);
But, I got error which will says CGRect is not an id type. So, how can I print the frame of CGRect for getting attributes.
Tarun Kumar
18-Jan-2016Yes, we can't print CGRect attributes directly in NSLog.
for that, cocoa provides us a method NSStringFromCGRect, because it will convert the CG structs into nsstring- below we are provided an example:
I'm providing some other functions which can help you to print CG struct values:
1. NSStringFromCGRect
2. NSStringFromCGSize
3. NSStringFromCGPoint
4. NSStringFromUIEdgeInsets
5. NSStringFromCGAffineTransform