I just want the easiest way to make a reflection under a UIImageVies that is easily managable.
Open the Library, look for "Tap Gesture Recognizer" object. Drag the object to your storyboard, and set the delegate to the image you want to trigger actions.
UIImage contains the data for an image. UIImageView is a custom view meant to display the UIImage .
An image object may contain a single image or a sequence of images for use in an animation. You can use image objects in several different ways: Assign an image to a UIImageView object to display the image in your interface. Use an image to customize system controls such as buttons, sliders, and segmented controls.
Just use the sample code in the the iPhone SDK library
Update: Link now updated to new location
As Phil says, you can have a "reflected" UIImageView instance:
@interface ReflectedImageView : UIView
{
@private
UIImageView *_imageView;
UIImageView *_imageReflectionView;
}
@property (nonatomic, retain) UIImage *image;
@end
And then, in your implementation, something like this
@implementation ReflectedImageView
@dynamic image;
- (id)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
self.backgroundColor = [UIColor clearColor];
// This should be the size of your image:
CGRect rect = CGRectMake(0.0, 0.0, 320.0, 290.0);
_imageReflectionView = [[UIImageView alloc] initWithFrame:rect];
_imageReflectionView.contentMode = UIViewContentModeScaleAspectFit;
_imageReflectionView.alpha = 0.4;
_imageReflectionView.transform = CGAffineTransformMake(1, 0, 0, -1, 0, 290.0);
[self addSubview:_imageReflectionView];
_imageView = [[UIImageView alloc] initWithFrame:rect];
_imageView.contentMode = UIViewContentModeScaleAspectFit;
[self addSubview:_imageView];
}
return self;
}
- (void)setImage:(UIImage *)newImage
{
_imageView.image = newImage;
_imageReflectionView.image = newImage;
}
- (UIImage *)image
{
return _imageView.image;
}
- (void)dealloc
{
[_imageView release];
[_imageReflectionView release];
[super dealloc];
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With