Image in iOSCanvas fade using alpha/transparent/other?

I have a canvas that displays an image. I’d like to do an “animation” effect of the image fading away to nothing. It looks like in the iOSGraphics, we have an alpha setting (https://documentation.xojo.com/api/deprecated/iosgraphics.html#iosgraphics-alpha), but either it’s not working right, not meant to have transparency on an image, or I’m doing something wrong.

Here is my canvas.paint:
g.Alpha = 0.5 // should be 50% transparent
g.DrawImage(TitleImage, 0, 0, me.Width, me.Height)

I also have iOSKit and iOSDesignExtensions in the project but not sure if there are any solutions or how to utilize them. iOSDesignExtensions seems to have a SetAlphaValueXC and AnimateAlphaXC, but I couldn’t get these to work

I am not sure AnimateAlphaXC will work on a Canvas, I never tried.
Is there any reason for using a Canvas instead of an iOSImageView?

I know the iOSImageView can have its alpha animated with AnimateAlphaXC

Comfort I guess! I’ll take a look at ImageView. One of the canvases i want to fade out is a button, so I’ll need a press up/down to handle the action of a button. I haven’t used an ImageWell/View in a long time. Just switched over to canvas years ago since I figured they were more versatile. I’ll check this out tomorrow. Thanks!

In that case you most certainly need to use an iOSButton.
Having a press up/down on an iOSImageView requires some declares.

Can you post a screenshot of the Canvas made button so I can tell you if it can be done with iOSButton?

I’m not at the computer at this moment, but it’s just an image of a circular button I found on pixabay. The canvas just draws the image as is. It’s not created by the canvas (drawing shapes to make a button).

In this button canvas, I also use in the press up/down a method to make it seem as though you’re pressing the button (shrinks a tad with press down, and then expands to normal size with press up)

Wondering if I can achieve the shrink/expand and also the fade while using the image well with having a canvas on top to handle the press up/down. Thoughts? This just occurred to me, and I can play around with tomorrow… if I get your blessing of course :smile:

You actually need an iOSButton :slight_smile:

First make sure that the images are the exact same size as the button.
Set the button’s images like this in its Open event:

me.SetImageXC(ImageExtensionsXC.ImageOriginalXC(Image_Normal), ControlExtensionsXC.UIControlState.Normal)

me.SetImageXC(ImageExtensionsXC.ImageOriginalXC(Image_Pressed), ControlExtensionsXC.UIControlState.Highlighted) //Required in your case to display a shrinked image. Not necessary otherwise

You can then use the following to animate the fade of the button:

aButton.AnimateAlphaXC(0.0, aDuration) //aDuration is a double representing duration in seconds of the animation. Defaults to 0.2

That one is going to be problematic. I am making the control’s height and width to adjust to the size of the screen in order for it to look larger on iPad or bigger iPhones and smaller on smaller devices

I am testing the AnimateAlphaXC on an iOSImageView but am getting an error

“iOSImageView” has no member named “AnimateAlphaXC”