ios开发之--CGRectGetXxx方法图解 和代码NSLog输出值
- (void)test { CGRect rect = CGRectMake(10, 20, 150, 30); // 最小Y坐标,即矩形的顶部top y坐标: minY = rect.y = 20.000000 NSLog(@"CGRectGetMinY = y = %f", CGRectGetMinY(rect)); // 最大Y坐标,即矩形的底部bottom y坐标:maxY = y + height = 50 NSLog(@"CGRectGetMaxY = y + height = %f", CGRectGetMaxY(rect)); // 最小x坐标,即矩形的左边x left坐标 : minX = x = 10 NSLog(@"CGRectGetMinX = x = %f", CGRectGetMinX(rect)); // 最大x坐标,集矩形的右边横坐标right maxX = x + width = 10 + 150 = 160 NSLog(@"CGRectGetMaxX = x + width = %f", CGRectGetMaxX(rect)); // 中点横坐标:midX = x + width/2 = 10 + 150/2 = 10 + 75 = 85 NSLog(@"CGRectGetMidX = x + width/2 = %f", CGRectGetMidX(rect)); // 中点纵坐标:midY = y + height / 2 = 20 + 30/2 = 20 + 15 = 35 NSLog(@"CGRectGetMidY = y + height /2 = %f", CGRectGetMidY(rect)); NSLog(@"CGRectGetWidth = rect.width = %f", CGRectGetWidth(rect)); // width = 150 NSLog(@"CGRectGetHeight = rect.height = %f", CGRectGetHeight(rect)); // height = 30 }
图解:
本文来自博客园,作者:稻草人11223,转载请注明原文链接:https://www.cnblogs.com/hero11223/p/7940999.html