Comments (5)
Hi @rgdev, items are re-layouted only when their container size change or when an item's flex property is modified. For any other changes, you must call markDirty()
to force a re-layout.
See https://github.com/layoutBox/FlexLayout#markdirty for more details.
In your case you need:
@objc func onButtonPressed(sender: UIButton) {
mainView.label.text = "goodbye"
mainView.label.flex.markDirty()
mainView.setNeedsLayout()
}
from flexlayout.
Such a silly mistake, thank you for the swift answer!
Do you think it would be possible to have UILabels to automatically mark themselves as dirty when their text field is updated in a futur version ?
from flexlayout.
@rgdev you can do that easily by subclassing the UILabel class (ex: Label / FlexLabel) and override the text
property setter.
You can also add an UILabel extension and add a property OR a method for setting the text that would call markDirty()
.
ex:
extension UILabel {
// Property
var flexText: String? {
get {
return self.text
}
set {
self.text = newValue
self.flex.markDirty()
}
}
// Method
func updateText(_ text: String) {
self.text = text
flex.markDirty()
}
}
from flexlayout.
Thank you @lucdion, I was actually wondering if you think such extension would be worth adding to FlexLayout directly.
from flexlayout.
I prefer not to add extension to base UIKit classes. There is always the possibility of name clashes with app' extensions.
I could add a subclass of UILabel, but I need to think about that.
Thanks for your input!
from flexlayout.
Related Issues (20)
- why not update yoga and yogakit? HOT 2
- Why is the subview constraint incorrect? HOT 1
- Nice work! HOT 1
- UILabel will get out of superview's bounds when text is too long HOT 2
- error: 'YGEnums.h' file not found HOT 3
- 'grow' not take up rest of space of cotainer. HOT 3
- 'YGEnums.h' file not found Error HOT 4
- Pods/FlexLayout/Sources/yoga/Yoga-internal.h:9:10: 'algorithm' file not found HOT 5
- how to use inline-flex feature HOT 1
- Are there plans to support macos? HOT 1
- FlexLayout package does not build with SwiftPM HOT 1
- 'YGEnums.h' file not found - When adding FlexLayout as dependency of another Swift Package. HOT 8
- ABI stability swift evolution support for different swift versions
- Use of bitwise '|' with boolean operands HOT 4
- Swift Error causing debugger not working
- Crash occurs when a `.wrapReverse` flexbox container has a `.display(.none)` item.
- Flexbox gap of Yoga in FlexLayout? HOT 2
- Child already has a owner, it must be removed first. HOT 6
- Override UITableViewCell
- The same code get different results in versions 1.3.33 and 2.0.07.
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 flexlayout.