<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">添加CGRect, CGPoint,CGSize,CGAffineTransform,UIEdgeInsets,UIOffset到</span>
方法:
@interface NSValue (NSValueUIGeometryExtensions)
+ (NSValue *)valueWithCGPoint:(CGPoint)point;
+ (NSValue *)valueWithCGVector:(CGVector)vector;
+ (NSValue *)valueWithCGSize:(CGSize)size;
+ (NSValue *)valueWithCGRect:(CGRect)rect;
+ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform;
+ (NSValue *)valueWithUIEdgeInsets:(UIEdgeInsets)insets;
+ (NSValue *)valueWithUIOffset:(UIOffset)insets NS_AVAILABLE_IOS(5_0);
- (CGPoint)CGPointValue;
- (CGVector)CGVectorValue;
- (CGSize)CGSizeValue;
- (CGRect)CGRectValue;
- (CGAffineTransform)CGAffineTransformValue;
- (UIEdgeInsets)UIEdgeInsetsValue;
- (UIOffset)UIOffsetValue NS_AVAILABLE_IOS(5_0);
@end
实例:
1.转NSValue
CGPoint point = CGPointMake(2,2);
NSValue *value = [NSValue valueWithCGPoint:point];
2.NSValue转其它
NSValue *value = [NSValue valueWithCGPoint:point];
CGRect rect = value.CGRectValue;