• iOS


    前言

    • 结构体,这个结构体用来表示事物的一个坐标点。

      	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);
    
  • 相关阅读:
    蔚来汽车笔试题---软件测试
    python 装饰器
    adb
    新手安装禅道至本地
    各种验证码应该如何给值
    int col = Integer.parseInt(args[0]);的用法
    找不到jsp文件:ctrl+shift+R
    通过服务器获取验证码
    Sublime Text 2: [Decode error
    爬虫爬取新闻(二)
  • 原文地址:https://www.cnblogs.com/QianChia/p/5780976.html
Copyright © 2020-2023  润新知