-(IBAction)displayinfo:(id)sender
{
sublayer = [CALayer layer];
if (appear == NO)
{
appear = YES;
sublayer.contents=(id)[UIImage imageNamed:@"infoPalette.png"].CGImage;
sublayer.frame= CGRectMake(300,200,350,250);
[self.view.layer addSublayer:sublayer];
}
else
{
[sublayer removeFromSuperlayer];
}
}
This allows the layer to appear but I can't remove it or hide it upon clicking the same button.
Swift 3.0 & Swift 4.0Set the sublayers property to nil to remove all sublayers from a view.
An object that manages image-based content and allows you to perform animations on that content.
Replace your existing code with this one
-(IBAction)displayinfo:(id)sender
{
if ( appear == NO)
{
sublayer = [CALayer layer];
appear = YES;
sublayer.contents=(id)[UIImage imageNamed:@"infoPalette.png"].CGImage;
sublayer.frame= CGRectMake(300,200,350,250);
[self.view.layer addSublayer:sublayer];
}
else
{
[sublayer removeFromSuperlayer];
}
}
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