iOS - OC NSPoint 位置
2016-08-17 17:45
344 查看
前言
结构体,这个结构体用来表示事物的一个坐标点。typedef CGPoint NSPoint; struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint;
1、NSPoint 结构体变量的创建与调用
// NSPoint 结构体变量的创建与赋值 // 先定义变量,再赋值 NSPoint point1; point1.x = 6; point1.y = 1; // 定义时直接赋值 NSPoint point2 = {7, 2}; // 给指定成员赋值 NSPoint point3 = {.y = 3, .x = 8}; // 使用函数赋值 NSPoint point4 = NSMakePoint(9, 4); // 使用等价的结构体定义,等价于 CGPoint point5 = CGPointMake(10, 5); NSPoint point5 = CGPointMake(10, 5); // NSPoint 结构体变量值的调用 NSLog(@"point1: %.0f, %.0f", point1.x, point1.y); NSLog(@"point2: %.0f, %.0f", point2.x, point2.y); NSLog(@"point3: %.0f, %.0f", point3.x, point3.y); NSLog(@"point4: %.0f, %.0f", point4.x, point4.y); NSLog(@"point5: %.0f, %.0f", point5.x, point5.y);
2、NSPoint 与 NSString 的相互转换
// NSPoint 转 NSString NSString *stringFronPoint = NSStringFromPoint(point5); // NSString 转 NSPoint NSPoint point6 = NSPointFromString(stringFronPoint);
相关文章推荐
- [原创文章] iOS和Android平台下地理位置信息带来的个人隐私问题
- iOS开发之在google地图上显示自己的位置
- IOS学习之Map,定位,标记位置的使用
- iOS 位置与地图相关
- WGS84坐标转火星坐标(iOS篇)解决位置偏移
- ios 使用CoreLocation框架确定他的物理位置
- iOS学习之Map,定位,标记位置的使用
- iOS地图位置开发
- ios模拟器中应用程序的安装位置
- iOS使用位置和方向服务(来自苹果apple官方)
- iOS开发之在google地图上显示自己的位置
- IOS 地图位置定位
- iOS基于百度地图的开发(1)——用户当前位置
- iPhone .app在 ios 模拟器上运行时,存放位置
- iOS开发关于位置的三个结构
- MKMapVIew学习系列1-iOS开发之在google地图上显示自己的位置
- iOS再曝漏洞:授权位置信息可导致照片库泄露
- IOS学习之Map,定位,标记位置的使用
- 自定义ios UIAlertView, 重排按钮位置
- ios tableCell 中同时获取点击的位置和所在的indexPath