BAFluidView
Overview
This view and its layer create a 2D fluid animation that can be used to simulate a filling effect.
For a how-to guide on use go to: https://antiguab.github.io/bafluidview/
This view and its layer create a 2D fluid animation that can be used to simulate a filling effect.
For a how-to guide on use go to: https://antiguab.github.io/bafluidview/
Hi :) I'm using BAFluidView with interface builder and autolayout, and I noticed a glitch when doing so:
http://d.pr/v/aR6
looks like the bezier path are computed at the starting size, but once autolayout resizes it to fit a bigger screen those values are no longer valid.
This sample shows the issue (you might need to hide the frontmost mask in IB, or just run it on your device and tilt it :) )
Any idea?
Thanks
Hey just want to let you know that doing just pod install on the Example folder triggered this error:
[!] Unable to satisfy the following requirements:
BAFluidView (from
../)
required by Podfile
BAFluidView (from
../)
required by Podfile
BAFluidView (= 0.1.1)
required by Podfile.lock
However, running pod update after solved it.
This should fix #14 although it might need to be documented in the readme since this happens also when you have a fluid view in a tab. Once the user switches tabs and goes back to the one with the fluid we should stop and restart the animation as well. In this case the UIApplicationWillResignActiveNotification
and UIApplicationDidBecomeActiveNotification
won't do the trick and we need to use for instance viewWillAppear/Disappear.
What do you think?
After applications goes to background and returns to foreground BAFluidView causes memory issue and app crashes with error : Terminated due to memory issue
. I thinks something strange is happening in getBezierPathValues
method but ca't figure it out.
Can you please give some idea how to fix this?
It would be cool if the accelerometer was used to influence how to fluid behaves. I guess that would require some sort of physics simulation, but it would still be cool :)
Hi, I'm trying to implement this great lib on swift, by writing this code:
let fluidView = BAFluidView(frame: self.view.frame, startElevation: 0.9)!
fluidView.strokeColor = UIColor.green
fluidView.fillColor = Constants.COLOR_BLUE
fluidView.keepStationary()
fluidView.startAnimation()
self.view.addSubview(fluidView)
and here is the preview:
I've been changing the value of startElevation from 0.1 to 9000, but the height of wave didn't change. I want to achieve that the height of wave is 1/4 of the height screen.
Thank you.
questionIf I start the app while holding my phone in my hand in an upright position, the tilting functionality works well. However, if app is launched while the device is flat on a desk or counter top, the tilting functionality will not work once the device is picked up.
Views have both a frame (coordinates in superview's coordinate system) and bounds (coordinates in own coordinate system) property, but if you transform a view, you should not use or rely on the frame property anymore. If you are using transformations, work with the bounds property only, not the frame property, as transformations are applied to the bounds, but aren't necessarily reflected accurately in frame.
kCAMediaTimingFunctionEaseInEaseOut
timing function to fillTo()
's CAKeyframeAnimation
for a nice, cold, smooth pour.I added BAFluidView to my screen and I use SWRevealViewController to menu navigation. IF I started to swipe in the menu, the View animation starts to lagging until I release the pull.
invalidHey, nice view, but in Swift the kBAFluidViewCMMotionUpdate doesn't work. Can you help me?
private func addFluidIndicator() {
if self.motionManager.deviceMotionAvailable
{
self.motionManager.deviceMotionUpdateInterval = 0.3
self.motionManager.startDeviceMotionUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: { (deviceManager, error) -> Void in
guard let deviceManager = deviceManager else { return }
let nc = NSNotificationCenter.defaultCenter()
let userInfo = NSDictionary(object: deviceManager, forKey: "data")
nc.postNotificationName(kBAFluidViewCMMotionUpdate, object: self, userInfo: userInfo as [NSObject : AnyObject])
})
}
let fluidView = BAFluidView(frame: UIScreen.mainScreen().bounds, startElevation: 0.5)
fluidView.fillColor = UIColor.blueColor()
fluidView.strokeColor = UIColor.whiteColor()
fluidView.keepStationary()
fluidView.startAnimation()
fluidView.startTiltAnimation()
self.view.addSubview(fluidView)
}
Great API, I think you could add the option for the user easily to change the speed by changing the value 7 on verticalAnimation.duration inside the method fillTo to a variable that the user of the API could set.
On adding a new BAFluidView to the same container view there is an issue where you can not animate it.
Other than that you work is great @antiguab π
Improvements you can do:
To reproduce: Start example app in landscape orientation Swipe down to get to Tilt example Notice incorrect Tilt (see screenshot) Changing orientation of device incorrectly changes fluid level (to near zero)
Note: Tilt does work correctly if you start app in portrait orientation
It seems like the app runs out of memory after a certain period of time.
Here is a console log:
malloc: can't allocate region
*** mach_vm_map(size=939524096) failed (error code=3) AppName
<img width="555" alt="Screenshot 2019-12-19 at 21 38 44" src="https://user-images.githubusercontent.com/3489125/71204297-7ae68800-22a8-11ea-855d-e5af690c9d16.png">
(7620,0x101ecebc0) malloc: *** set a breakpoint in malloc_error_break to debug
I'm working on a project where the background liquid "fill" animation will need to be paused by a user interaction. I'd like to have the waves continue to crest, even when the animation is not filling the view.
Have you considered adding something like this?
I'm struggling with the implementation, but if it's easy, could you share some initial direction?
Thanks!
I am trying to animate the FluidView from top (1.0) to bottom (0.0) On doing so, the FluidView just remains at the top, without any reverse animation.
I tried animating from 1.0 to 0.1, with a fillDuration of 7, but the FluidView just quickly animates to 0.1 in one second.
Here is the code for reference:
fluidView = BAFluidView(frame: fluidViewFrame, maxAmplitude: 25, minAmplitude: 20, amplitudeIncrement: 5, startElevation: 1.0)
fluidView.backgroundColor = LIGHTER_GRAY
fluidView.fillAutoReverse = false
fluidView.fillDuration = 7
fluidView.strokeColor = OFF_WHITE
fluidView.fillRepeatCount = 1
fluidView.fillColor = WHITE
fluidView.fill(to: 0.0)
BatteryView Simple battery shaped UIView. Usage let batteryView = BatteryView(frame: smallRect) batteryView.level = 42 // anywhere in 0...100 batteryV
Geometry Geometry is a UIView and CGRect extension that lets you work with view and rect geometry easier. It adds the following properties to UIView:
ShadowView is an iOS Shadow library that makes view's shadow implementation easy and sweet ?? ?? . Add simple shadows to add a gaussian blurred projec
SwiftyUI High performance and lightweight UIView, UIImage, UIImageView, UIlabel, UIButton and more. Features SwiftyView GPU rendering Image and Color
Twinkle β¨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate
IDView Custom Beautiful UIView For Handling IDs in iOS Setup Set the placeholder images for the front and back faces. override func viewDidLoad()
FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn't use any Method S
SwiftUIKitView Easily use UIKit views in SwiftUI. Convert UIView to SwiftUI View Create Xcode Previews from UIView elements SwiftUI functional updatin
A swift PropertyWrapper to provide automatic NSView/UIView invalidation when the properties value changes. It duplicates the @Invalidating propertyWrapper for build targets prior to macOS 12 and iOS 15.
SwiftVideoBackground is an easy to use Swift framework that provides the ability to play a video on any UIView. This provides a beautiful UI for login
Easily add drop shadows, borders, rounded corners to a UIView. Installation CocoaPods Add the follwing to your Podfile: pod 'Shades' Usage Storyboard
anchorage Single file UIView drag and drop system anchors.mp4 License Copyright
BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r
ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw
Arale A custom stretchable header view for UIScrollView or any its subclasses with UIActivityIndicatorView support for reloading your content. Built f
BreakOutToRefresh Play BreakOut while loading - A playable pull to refresh view using SpriteKit BreakOutToRefresh uses SpriteKit to add a playable min
CountryPickerView CountryPickerView is a simple, customizable view for selecting countries in iOS apps. You can clone/download the repository and run
Cool Animated music indicator view written in Swift. ESTMusicIndicator is an implementation of NAKPlaybackIndicatorView in Swift for iOS 8. ζ¬δΊΊθδ½ηδΉ¦η±γLa
Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi