I have a laid out views in Storyboard. My structure has the following elements:
- Off Button Background (UIView), Main View
- Off Icon (UIButton), Sub View
- Off Button Label (UILabel), Sub View
Here's how that looks:
Now, I want to animate the "Off Button Bg" to
alpha = 0, but leave the "Off Icon" and "Off Button Label" at
Is that possible given my current structure, where the subviews are nested under "Off Button Bg"? Ideally, I'd like to keep the subviews nested under "Off Button Bg" to enable animating all these elements as a whole in other places.
That is not possible given your current structure. You won't be able to nest those views as subviews without affecting the alpha of those views when you change the alpha of the UIView. The documentation of the alpha property states
However, the transparency imparted by that alpha value affects all of the view's contents, including its subviews. For example, a subview with an alpha value of 1.0 that is embedded in a parent view with an alpha value of 0.5, appears onscreen as if its alpha value is also 0.5.
However, you can achieve that by placing the
Off Icon (button) and
Off Button Label at the same level in the hierarchy as
Off Button Bg, and then setting the constraints of Off Button Bg to align with the other views, but you'll have to manage the alpha values of the views independently.
- iOS animating object goes back to original position
- Prevent UITableView from receiving two touches (nested pop animation can result in corrupted navigation bar)
- UITableView DidSelectRowAtIndexPath?
- Sorting NSArray of dictionaries by value of a key in the dictionaries
- Swift - detailCalloutAccessoryView Isn't Updating Data
- how to ignore tashkeel character counting in text wrapping in corona sdk?
- How to check if current coordinates are within a radius of other coordinates
- Can't open Sqlite database in read-only mode
- How do i use array.filter to filter a class object based on a property?
- CoreAudio AudioObjectRemovePropertyListener not working in Swift