- July 30, 2025
- Mins Read
Showing some kinds of the weather effect, written in Swift4.2.
This code style is the Protocol Oriented Programming
.
To show the vector animation made by After Effect, Lottie can be used instead of UIImageView.
Add the following to your Podfile
.
pod “URWeatherView”
lottie-ios-extension
(But, you don’t need to care about this, when using URWeatherView. It’s already included the dependency.)
Add the following to your Cartfile
.
github “jegumhon/URWeatherView”
lottie-ios-extension
(But, you don’t need to care about this, when using URWeatherView. It’s already included the dependency.)
See the Example
folder.
Run pod install
and open the .xcworkspace.
(The Example source is made for using Carthage.
So, you remove the linked frameworks in General
of the project settings.
And then, you remove the run script of Carthage in Build Phases
of the project settings.)
or
Run carthage update
and open the .xcodeproj.
import URWeatherView
// for example…
// You can use the xib or storyboard to show the URWeatheView…
@IBOutlet var mainView: URWeatherView!
override func viewDidLoad() {
super.viewDidLoad()
// set the main Image to apply the weather effects…
// and set the backgroundImage, if you want to apply…
self.mainView.initView(mainWeatherImage: #imageLiteral(resourceName: “buildings”), backgroundImage: #imageLiteral(resourceName: “bluesky.en”))
// or, to use Lottie, do like below..
// self.mainView.initView(dataNameOfLottie: “data”, backgroundImage: #imageLiteral(resourceName: “bluesky.en”))
}
func showWeather() {
let weather: URWeatherType = .cloudy
self.mainView.startWeatherSceneBulk(weather, debugOption: true, additionalTask: {
// task what you want to do after showing the weather effect…
})
}
func removeWeather() {
self.mainView.stop()
}
Using or composing the functions in the URWeatherView, you can customize the weather effects. The default configurable parameters are like below.
case .cloudy:
// self.mainView.startWeatherSceneBulk(cell.weather, duration: 33.0, debugOption: self.segment.selectedSegmentIndex == 0)
self.mainView.initWeather()
self.mainView.setUpperImageEffect(customImage: nil)
let option = UREffectCloudOption(CGRect(x: 0.0, y: 0.5, width: 1.0, height: 0.5), angleInDegree: 0.0, movingDuration: 33.0)
self.mainView.startWeatherScene(cell.weather, duration: 33.0, userInfo: [URWeatherKeyCloudOption: option])
1. Taking Action When a Property Changes: Property Observers Swift lets you observe and respond to changes in a property’s ...
1. Creating Your Own Structs In Swift, a struct is a value type that you define with the struct keyword. ...
1. Trailing Closure Syntax When the last parameter to a function is a closure, you can write that closure after ...
1. What Is a Closure (and Why Swift Loves Them) A closure in Swift is a self-contained block of functionality ...