标签:
通过下面的代码,又可以将NSValue转换成CGRect,CGPoint等类型的数值。
CGRect imageRect = [[self.lockImageRectArray objectAtIndex:l] CGRectValue];
通过NSValue就可以实现CGxxx类型的数值存储在NSMutable,NSDictionary类型的数组中。
@interface NSValue (NSValueUIGeometryExtensions)
+ (NSValue *)valueWithCGPoint:(CGPoint)point;
+ (NSValue *)valueWithCGSize:(CGSize)size;
+ (NSValue *)valueWithCGRect:(CGRect)rect;
+ (NSValue *)valueWithCGAffineTransform:(CGAffineTransform)transform;
+ (NSValue *)valueWithUIEdgeInsets:(UIEdgeInsets)insets;
+ (NSValue *)valueWithUIOffset:(UIOffset)insets __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
- (CGPoint)CGPointValue;
- (CGSize)CGSizeValue;
- (CGRect)CGRectValue;
- (CGAffineTransform)CGAffineTransformValue;
- (UIEdgeInsets)UIEdgeInsetsValue;
- (UIOffset)UIOffsetValue __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
@end
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@
"lockButton.png"
]];
imageView.frame = CGRectMake(10 * (l + 1) + imageView.frame.size.width * l, 120 + 50 * r, imageView.frame.size.width, imageView.frame.size.height);
[self.lockImageRectArray addObject:[NSValue valueWithCGRect:imageView.frame]];
[self addSubview:imageView];
标签:
原文地址:http://www.cnblogs.com/wcLT/p/4707239.html