Comments (2)
Hi @RealBug, thanks for your contribution!
Right you can use a custom cancelView
in a subclass of XLActionController
by creating it in viewDidLoad
before calling super. Take a look to the next code snippet:
open class CustomActionController: ActionController<CustomCell, ActionData, CustomHeaderView, SpotifyHeaderData, UICollectionReusableView, Void> {
public override init(nibName nibNameOrNil: String? = nil, bundle nibBundleOrNil: Bundle? = nil) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
settings.cancelView.showCancel = true
settings.cancelView.backgroundColor = .lightGray
// Add all needed settings
}
open override func viewDidLoad() {
cancelView = {
let cancelView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.size.width, height: settings.cancelView.height))
cancelView.backgroundColor = settings.cancelView.backgroundColor
let button = UIButton()
button.backgroundColor = .white
button.setTitle("Cancel", for: .normal)
button.setTitleColor(.black, for: .normal)
button.translatesAutoresizingMaskIntoConstraints = false
cancelView.addSubview(button)
cancelView.addConstraints(
NSLayoutConstraint.constraints(withVisualFormat: "H:|-20-[button]-20-|", options: [], metrics: nil, views: ["button": button]) +
NSLayoutConstraint.constraints(withVisualFormat: "V:|-5-[button]-5-|", options: [], metrics: nil, views: ["button": button])
)
return cancelView
}()
super.viewDidLoad()
}
}
We are planning to add support for a CancelViewSpec
in a future version, which will allow developers to completely customize the cancelView
's style similarly to how the header is defined. But for now you can do something similar to the code shown above.
from xlactioncontroller.
Awesome, thank you for your great work !
from xlactioncontroller.
Related Issues (20)
- can not convert HOT 1
- Accessibility support
- Not able to run it on Simulator HOT 1
- XLActionController not Compatible with swift 5 because when i import to my VC , it doesn't know any class for example TweetbotActionController class
- dyld: lazy symbol binding failed: Symbol not found: _$s18XLActionController013YoutubeActionB0CMa
- Xcode 11 HOT 5
- safe area background HOT 1
- XLActionController/Spotify Terminating app due to uncaught exception
- XLActionController/Skype Terminating app due to uncaught exception HOT 2
- Swift Package Manager
- a layout bug in Spotify action controller HOT 2
- Periscope add safearea subview
- How to disable auto rotate
- Add SPM Support HOT 4
- Where to place code to 'show more options' HOT 3
- cover safe areas
- Message from debugger: Terminated due to signal 9
- Is there a way to remove cancel button animation?
- In the Spotify style, the Cancel button obscures the following option HOT 1
- SPM new issues with Xcode 13.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlactioncontroller.