Hey so I have been trying to implement an ad banner view below the split view controller of my app. I managed to do it by creating a BannerViewController, which resizes the splitViewController and places the banner at the bottom, which works. However, now I notice that tapping an item in the list in the TableViewController doesn't work on iPhone. It stays selected like on iPad, so it must think it is on iPad and has to display the detail next to the master. The segue is hooked up in Interface Builder from the UITableViewCell to the navigation controller of the detail view. And it was all working fine even for a while after implementing the banner controller, but just stopped this morning.
I have tried calling performSegue in didSelectRowAtIndexPath, and prepareForSegue is called every time but usually does not show anything on iPhone.
Here is BannerViewController:
class BannerViewController: UIViewController, GADBannerViewDelegate {
var bannerView = GADBannerView()
var showingBanner = false
var contentView, bannVC: UIView!
var originalFrame: CGRect!
init(contentVC: UIViewController) {
contentView = contentVC.view
originalFrame = contentView.frame // Store the original frame of the content view for later use
super.init(nibName: nil, bundle: nil)
// If banner is hidden, position off screen (x > window.height) and make contentView size of window
view.addSubview(contentView)
// Create banner view
setupAds()
}
// Required init, just call super
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
// Update the position of the banner on the screen
override func viewDidLayoutSubviews() {
bannerView.frame = CGRect(x: 0, y: contentView.frame.size.height, width: contentView.frame.size.width, height: 50)
}
// MARK: - Adverts
// Checks if ads have been disabled by buying the in app purchase
func checkAdsDisabled() -> Bool {
return Product.findBy(identifier: ProductRepo.DisableAds)?.purchased ?? false
}
func setupAds() {
if (!checkAdsDisabled()) {
// Ads have not been disabled, set them up
bannerView.adUnitID = "ca-app-pub-123456/xyz"
bannerView.translatesAutoresizingMaskIntoConstraints = false
bannerView.adSize = kGADAdSizeSmartBannerPortrait
bannerView.delegate = self
bannerView.rootViewController = self
let request: GADRequest = GADRequest()
request.testDevices = ["xyz"] // My iPhone
bannerView.load(request)
// Initially position off screen
view.addSubview(bannerView)
hideBanner()
}
}
// Hide banner and update view positions
func hideBanner() {
contentView.frame.size.height = originalFrame.size.height
view.layoutSubviews()
showingBanner = false
}
// Show banner and update view positions
// Called by adViewDidReceiveAd
func showBanner() {
contentView.frame.size.height = contentView.superview!.frame.size.height - bannerView.frame.size.height
view.layoutSubviews()
showingBanner = true
}
// MARK: - GADBannerViewDelegate
/// Tells the delegate an ad request loaded an ad.
func adViewDidReceiveAd(_ bannerView: GADBannerView!) {
print("adViewDidReceiveAd: Banner loaded")
if !showingBanner{
showBanner()
}
}
}
If it helps, also I am using SearchController in the master view. When tapping the search bar I get the warning Presenting view controllers on detached view controllers is discouraged, which may be related, but I can't get any info out of that.
Related
I am trying to recreate the bottom drawer functionality seen in Maps or Siri Shortcuts by using a UIPresentationController by having it recognise user input and updating the frameOfPresentedViewInContainerView accordingly. However I want this mechanism to work independently of the presented UIViewController as much as possible so I'm trying to have the presentation controller add a handle area above the view. Ideally the view of the presented controller and the handle are should both recognise user input.
This works for the presented view, however any view I add to it responds to no UIGestureRecognizer at all. Am I missing something?
class PresentationController: UIPresentationController {
private let handleArea: UIView = UIView()
override var frameOfPresentedViewInContainerView: CGRect {
// Return some frame for now
return CGRect(x: 0, y: 250, width: containerView!.frame.width, height: 500)
}
override func presentationTransitionWillBegin() {
// Unwrap presented view
guard let presentedView = self.presentedView else {
return
}
// Set color
self.handleArea.backgroundColor = UIColor.green
// Add to view hierachy
presentedView.addSubview(self.handleArea)
// Set constraints
self.handleArea.trailingAnchor.constraint(equalTo: presentedView.trailingAnchor).isActive = true
self.handleArea.leadingAnchor.constraint(equalTo: presentedView.leadingAnchor).isActive = true
self.handleArea.bottomAnchor.constraint(equalTo: presentedView.topAnchor).isActive = true
self.handleArea.heightAnchor.constraint(equalToConstant: 56).isActive = true
self.handleArea.translatesAutoresizingMaskIntoConstraints = false
// These don't help
self.handleArea.isUserInteractionEnabled = true
presentedView.isUserInteractionEnabled = true
presentedView.bringSubviewToFront(self.handleArea)
}
override func presentationTransitionDidEnd(_ completed: Bool) {
if completed {
// Add gesture recognizer
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.onHandleAreaTapped(sender:)))
self.handleArea.addGestureRecognizer(tapGestureRecognizer)
}
}
override func dismissalTransitionDidEnd(_ completed: Bool) {
// Remove subview
self.handleArea.removeFromSuperview()
}
// MARK: - Responder
#objc private func onHandleAreaTapped(sender: UITapGestureRecognizer) {
print("tap") // No output
}
}
I managed to solve it by adding both the handle area and the view of the presentedViewController to a custom view and then overriding the presentedView property and returning my custom view.
I want a popover without rounded corners and with no arrow.
I have done the following code but it did not work:
//SerachPopViewController.swift
//MARK: InitCoder
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//popover settings
//popoverPresentationController!.permittedArrowDirections = .Any
modalPresentationStyle = .Popover
popoverPresentationController!.delegate = self
//permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.preferredContentSize = CGSize(width:340,height:380)
}
//QueryTableViewController.swift
#IBAction func searchFilter(sender: AnyObject) {
let searchPopController = storyboard!.instantiateViewControllerWithIdentifier("SerachPopViewController") as! SerachPopViewController
searchPopController.serachPopDelegate = self
searchPopController.modalPresentationStyle = .Popover
searchPopController.preferredContentSize = CGSize(width:340,height:380)
let popoverPresentationController = searchPopController.popoverPresentationController
popoverPresentationController!.sourceView = self.view;
popoverPresentationController!.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
popoverPresentationController!.permittedArrowDirections = UIPopoverArrowDirection();
self.presentViewController(searchPopController, animated: true, completion: nil)
}
I am able to display popover view with arrow and rounded arrow.
Please help me to achieve:
popup view with rectangle corner
popup view without direction arrows
Using the concept above, you can also set the corner radius in the completion parameter.
Swift 3
let popoverViewController: UIViewController = // Some view controller to be presented in a popover
// Set popover properties here...
// i.e. popoverViewController.modalPresentationStyle = .popover
present(popoverViewController, animated: true, completion: {
popoverViewController.view.superview?.layer.cornerRadius = 0
// Additional code here
})
In iOS 11 its not possible to use #SHN solution for removing rounded corners. The corner radius is set to default value after viewWillAppear.
Radius must be set in viewDidAppear method
override func viewDidAppear(_ animated: Bool) {
view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
To get popover without arrow when you are initiating popover, use:
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
For popover without corner radius, in the popover content view controller use:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Do any additional setup after loading the view, typically from a nib.
self.view.superview?.layer.cornerRadius = 0.0;
}
I was not 100% happy with shawnynicole's answer because I realized the change from the rounded to the rectangular corners are notable/visible.
So I came up with this: subclass the view controller (in my case it was an UINavigationController) and override viewDidLayoutSubviews and update corners there. This is better because corners change animation is not visible and it will be updated every time needed (on rotations, etc).
It works in iOS11 and probably should work on others versions too.
class PopoverNavigationController: UINavigationController {
#IBInspectable var cornerRadius: Int = -1
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let r = CGFloat(cornerRadius)
if r >= 0 && view.superview?.layer.cornerRadius != r {
view.superview?.layer.cornerRadius = r
}
}
}
I don't know why It does't work on my Simulator with iOS11.1 until trying setting backgroundColor.I added function viewWillTransition for rotating device.
override func viewDidAppear(_ animated: Bool) {
view.superview?.backgroundColor = UIColor.white
view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
view.superview?.backgroundColor = UIColor.white
view.superview?.layer.cornerRadius = 0
super.viewWillTransition(to: size, with: coordinator)
}
For Swift 4, in case you present your popover embedded in a navigation controller:
override func viewDidAppear(_ animated: Bool) {
navigationController?.view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
That's the way I do it in order to achieve such a functionality which works also on device rotation:
In the view controller that you set as a popover add the following code:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
view.superview?.layer.cornerRadius = 0
}
extension MyPopoverViewController: UIPopoverPresentationControllerDelegate {
func popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>) {
self.view.setNeedsLayout()
}
Finally, set your popover's delegate to the instance of this view controller before presenting it:
...
popover.delegate = myPopoverViewController
present(myPopoverViewController, animated: true)
Many of these answers fix the OP's question about corner radius, but you can get the same effect by changing your presented view controller's top view's background to clear. Then just round the corners of the next top view to the desired amount (or not, if you want it to be a straight top).
I prefer this way because it gives you more WYSIWYG control over the presented view. For example, you can present a floating square by just centering a view in the view controller and presenting it.
I have a banner view and want to have a custom close button. My problem is that the button is displayed before the ad is loaded and displayed.
class RootVC: UIViewController, GADBannerViewDelegate {
var googleAdBanner: GADBannerView!
var googleBannerCloseBtn: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
googleAdBanner = GADBannerView(frame:CGRectMake(0,0,100,100))
googleAdBanner.center = CGPointMake(self.view.bounds.size.width / 2, self.view.bounds.size.height / 2)
googleAdBanner.adUnitID = "xx"
googleAdBanner.rootViewController = self
googleAdBanner.loadRequest(GADRequest())
adViewWillPresentScreen(googleAdBanner)
googleAdBanner.delegate = self
self.view.addSubview(googleAdBanner)
}
func adViewWillPresentScreen(bannerView: GADBannerView!) {
googleBannerCloseBtn = UIButton(frame: CGRectMake( 5 , 5, 25, 25))
googleBannerCloseBtn.backgroundColor = UIColor.clearColor()
googleBannerCloseBtn.setImage(UIImage(named: "closeBtn"), forState: .Normal)
googleBannerCloseBtn.setTitle("Click Me", forState: UIControlState.Normal)
googleBannerCloseBtn.addTarget(self, action: #selector(RootVC.buttonAction(_:)), forControlEvents: UIControlEvents.TouchUpInside)
googleBannerCloseBtn.tag = 1
googleAdBanner.addSubview(googleBannerCloseBtn)
}
How do I present the button only when the GADBannerView has loaded an ad and is presented?
Same behavior with adViewDidReceiveAd. The button is visible, even if the GADBannerView is "invisible" because there is no ad loaded currently.
Screens as requested. As you see, the button, that is a subView of the GADBannerView is displayed before the ad itself is displayed.
I've commented out alot of the logic in this example. The only thing that I didn't mention was that you will need to create two Ad Unit ID's. One for your GADBannerView and one for your GADInterstitial on AdMob.com.
import UIKit
import GoogleMobileAds // Import AdMob
class ViewController: UIViewController, GADBannerViewDelegate, GADInterstitialDelegate { // Include our delegates
// Create our ads
var banner = GADBannerView(adSize: kGADAdSizeBanner) // kGADAdSizeBanner is a default banner size
var interstitial = GADInterstitial(adUnitID: "YourInterstitialAdUnitID")
override func viewDidLoad() {
super.viewDidLoad()
// View has loaded so lets setup our ads initially
setupAds()
}
// MARK: - Setup Ads
func setupAds() {
// Setup our banner ad
banner.adUnitID = "YourBannerAdUnitID"
banner.rootViewController = self
banner.delegate = self
// Hide our banner initially until it loads an ad
// Not doing this is why your close button was visible
// GADBannerView's with no ad are essentially "clear", not hidden
banner.alpha = 0.0
banner.loadRequest(GADRequest())
// Position banner on bottom of view
banner.frame = CGRect(x: 0.0,
y: view.frame.height - banner.frame.height,
width: view.frame.width,
height: banner.frame.height)
// Create your button here and add it as a subview to banner
// banner.addSubview(closeButton)
view.addSubview(banner)
// Setup our interstitial ad initially
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
}
// MARK: - Load Interstitial Ad
func loadFullScreenAd() {
// GADInterstitial's are single use. You have to create a new GADInterstitial for each presentation
// So, if you'd like to show more than one GADInterstitial in your apps session we need this
// This func will be used to create a new GADInterstitial after one has been displayed and dismissed
interstitial = GADInterstitial(adUnitID: "YourInterstitialAdUnitID")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
}
// MARK: - Show Interstitial Ad
func showFullScreenAd() {
// Call this function when you want to present the interstitial ad
// ie. game over, transition to another vc, etc...
// Make sure you give atleast a few seconds for this ad to load before atempting to present it
// For example, don't try to present this ad in viewDidAppear
// Check if the interstitial ad is loaded before trying to present it
if interstitial.isReady {
interstitial.presentFromRootViewController(self)
}
}
// MARK: - Close Button Action
func closeButtonAction() {
// This is where we will handle your close button that you've added to your GADBannerView
// You can handle this two ways and it depends on what you'd like to do
// If you don't want to show the banner ad again during the entire app session you would hide the banner
// This way even if we change the alpha values in our delegate methods the banner will remain hidden
banner.hidden = true
// Another way you can handle the close button would be to hide the banner until another banner ad is loaded
// I believe the refresh rate for banner ads is 45-60 seconds. You can customize the refresh time on AdMob.com
// So, this way if the user tapped the close button the banner would fade out
// But, when another banner ad is loaded the banner would fade back in because of the code in our adViewDidReceiveAd delegate method
UIView.animateWithDuration(0.2) {
self.banner.alpha = 0.0
}
/////* Choose which way you'd like to handle the close button and remove the code for the other */////
}
// MARK: - GADBannerView Delegate Methods
func adViewDidReceiveAd(bannerView: GADBannerView!) {
print("adViewDidReceiveAd")
// We received an ad so lets show it
// You could even fade in the banner if you'd like
UIView.animateWithDuration(0.2) {
self.banner.alpha = 1.0
}
}
func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
print("banner didFailToReceiveAdWithError: \(error)")
// We received an error when trying to load our GADBannerView
// Lets hide it because we don't have an ad
// You could also fade this out if you'd like
UIView.animateWithDuration(0.2) {
self.banner.alpha = 0.0
}
}
// MARK: - GADInterstitial Delegate Methods
func interstitialDidReceiveAd(ad: GADInterstitial!) {
print("interstitialDidReceiveAd")
}
func interstitialWillPresentScreen(ad: GADInterstitial!) {
print("interstitialWillPresentScreen")
// If you needed to pause anything in your app this would be the place to do it
// ie. sounds, game state, etc...
}
func interstitialDidDismissScreen(ad: GADInterstitial!) {
print("interstitialDidDismissScreen")
// The GADInterstitial has been shown and dismissed by the user
// Lets load another one for the next time we want to show a GADInterstitial
loadFullScreenAd()
// If you paused anything in the interstitialWillPresentScreen delegate method this is where you would resume it
}
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
print("interstitial didFailToReceiveAdWithError: \(error)")
}
}
Also, if you plan on presenting the GADInterstitial often in your application I'd recommend disabling video ads on AdMob.com for that Ad Unit ID. AdMob interstitial video ads disable the close button for 5 seconds, kind of like the skip button on YouTube, and will aggravate your users instantaneously. If you're rarely showing the GADInterstitial then I'd leave the video ads enabled.
I want a popover without rounded corners and with no arrow.
I have done the following code but it did not work:
//SerachPopViewController.swift
//MARK: InitCoder
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
//popover settings
//popoverPresentationController!.permittedArrowDirections = .Any
modalPresentationStyle = .Popover
popoverPresentationController!.delegate = self
//permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
self.preferredContentSize = CGSize(width:340,height:380)
}
//QueryTableViewController.swift
#IBAction func searchFilter(sender: AnyObject) {
let searchPopController = storyboard!.instantiateViewControllerWithIdentifier("SerachPopViewController") as! SerachPopViewController
searchPopController.serachPopDelegate = self
searchPopController.modalPresentationStyle = .Popover
searchPopController.preferredContentSize = CGSize(width:340,height:380)
let popoverPresentationController = searchPopController.popoverPresentationController
popoverPresentationController!.sourceView = self.view;
popoverPresentationController!.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds),0,0)
popoverPresentationController!.permittedArrowDirections = UIPopoverArrowDirection();
self.presentViewController(searchPopController, animated: true, completion: nil)
}
I am able to display popover view with arrow and rounded arrow.
Please help me to achieve:
popup view with rectangle corner
popup view without direction arrows
Using the concept above, you can also set the corner radius in the completion parameter.
Swift 3
let popoverViewController: UIViewController = // Some view controller to be presented in a popover
// Set popover properties here...
// i.e. popoverViewController.modalPresentationStyle = .popover
present(popoverViewController, animated: true, completion: {
popoverViewController.view.superview?.layer.cornerRadius = 0
// Additional code here
})
In iOS 11 its not possible to use #SHN solution for removing rounded corners. The corner radius is set to default value after viewWillAppear.
Radius must be set in viewDidAppear method
override func viewDidAppear(_ animated: Bool) {
view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
To get popover without arrow when you are initiating popover, use:
popover!.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
For popover without corner radius, in the popover content view controller use:
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Do any additional setup after loading the view, typically from a nib.
self.view.superview?.layer.cornerRadius = 0.0;
}
I was not 100% happy with shawnynicole's answer because I realized the change from the rounded to the rectangular corners are notable/visible.
So I came up with this: subclass the view controller (in my case it was an UINavigationController) and override viewDidLayoutSubviews and update corners there. This is better because corners change animation is not visible and it will be updated every time needed (on rotations, etc).
It works in iOS11 and probably should work on others versions too.
class PopoverNavigationController: UINavigationController {
#IBInspectable var cornerRadius: Int = -1
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let r = CGFloat(cornerRadius)
if r >= 0 && view.superview?.layer.cornerRadius != r {
view.superview?.layer.cornerRadius = r
}
}
}
I don't know why It does't work on my Simulator with iOS11.1 until trying setting backgroundColor.I added function viewWillTransition for rotating device.
override func viewDidAppear(_ animated: Bool) {
view.superview?.backgroundColor = UIColor.white
view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
view.superview?.backgroundColor = UIColor.white
view.superview?.layer.cornerRadius = 0
super.viewWillTransition(to: size, with: coordinator)
}
For Swift 4, in case you present your popover embedded in a navigation controller:
override func viewDidAppear(_ animated: Bool) {
navigationController?.view.superview?.layer.cornerRadius = 0
super.viewDidAppear(animated)
}
That's the way I do it in order to achieve such a functionality which works also on device rotation:
In the view controller that you set as a popover add the following code:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
view.superview?.layer.cornerRadius = 0
}
extension MyPopoverViewController: UIPopoverPresentationControllerDelegate {
func popoverPresentationController(_ popoverPresentationController: UIPopoverPresentationController, willRepositionPopoverTo rect: UnsafeMutablePointer<CGRect>, in view: AutoreleasingUnsafeMutablePointer<UIView>) {
self.view.setNeedsLayout()
}
Finally, set your popover's delegate to the instance of this view controller before presenting it:
...
popover.delegate = myPopoverViewController
present(myPopoverViewController, animated: true)
Many of these answers fix the OP's question about corner radius, but you can get the same effect by changing your presented view controller's top view's background to clear. Then just round the corners of the next top view to the desired amount (or not, if you want it to be a straight top).
I prefer this way because it gives you more WYSIWYG control over the presented view. For example, you can present a floating square by just centering a view in the view controller and presenting it.
I am trying to animate the root-view-controller-change in my app. After I swap the view controllers, I load the data necessary for the 2nd controller right away. While the data is loading, I show a loader(MBProgressHUD). This is my function for swapping the view controllers:
class ViewUtils {
class func animateRootViewController(duration: NSTimeInterval, changeToViewController: UIViewController) {
let window = UIApplication.sharedApplication().delegate?.window?
if window == nil {
return
}
UIView.transitionWithView(window!,
duration: duration,
options: UIViewAnimationOptions.TransitionFlipFromLeft | UIViewAnimationOptions.AllowAnimatedContent,
animations: {
window!.rootViewController = changeToViewController
},
completion: nil
)
}
}
All good with this but one thing - it totally breaks the loader. I am attaching an imagine of what's happening:
This is the 2nd view controller while rotating. Once the rotation is complete, the loader appears just fine, both the spinner and the text tween to the correct position in the rounded rectangle.
I really don't understand why this happens, would somebody explain it to me, please? Is there a way to prevent it?
The code of the 2nd view controller where I show the loader:
override func viewDidLoad() {
super.viewDidLoad()
hud = HUD(containingView: view)
hud.show()
createBackground()
}
And my hud class:
class HUD {
private var hudBG: UIView!
private var view: UIView!
private(set) var isShown = false
init(containingView: UIView) {
view = containingView
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func show() {
if !isShown {
if(hudBG == nil) {
hudBG = UIView(frame: CGRectMake(0, 0, view.bounds.width, view.bounds.height))
hudBG.backgroundColor = UIColor(white: 0, alpha: 0.4)
}
view.addSubview(hudBG)
let hud = MBProgressHUD.showHUDAddedTo(view, animated: true)
hud.mode = MBProgressHUDModeIndeterminate
hud.labelText = "Cargando"
hudBG.alpha = 0
UIView.animateWithDuration(0.3, animations: { () -> Void in
self.hudBG.alpha = 1
})
isShown = true
}
}
func hide() {
if isShown {
UIView.animateWithDuration(0.3, animations: {
() -> Void in
self.hudBG.alpha = 0
}, completion: {
(b) -> Void in
self.hudBG.removeFromSuperview()
})
MBProgressHUD.hideHUDForView(view, animated: true)
isShown = false
}
}
}
Thanks a lot for any ideas!
You are adding the hud to a view that is not properly initialized yet.
If you are loading the view controller from a xib or storyboard, the view and it's subviews have the size as they were loaded from interface.
You have to add the hud after the views have been resized to their final size.
If you move
hud = HUD(containingView: view)
hud.show()
to viewDidLayoutSubviews, it should work fine.
I noticed a similar problem when moving an app from iOS 7 to iOS 8. During animations, especially when scaling was involved, the view positions got distorted.
I am pretty sure it's a bug. The simplest workaround is to animate only screenshots or view snapshots, not actual views - it's more work and you can't have views animating when the main animation is in progress but in general it's a more stable solution.