Comments (38)
And there is one more question. How to create such a layout, as in the picture? There are two texts that are always located at the edges opposite each other and between them the line.
from flexlayout.
@lucdion I need your help. Error -- Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2
in xCode 9.1
from flexlayout.
@sLm-s if you use carthage, delete your Carthage
directory and reintall carthage modules. If you use pod, be sure to clean up everything before rebuilding (even sometimes the derived data directory).
from flexlayout.
For your problem above, sorry I didn't have the time yet to test it using flexbox.
Using PinLayout it would be:
redText.pin.left().vCenter().fitSize()
purpleText.pin.right().vCenter().fitSize()
lineView.pin.after(of: redText).before(of: purpleText).vCenter().marginHorizontal(10)
I'll test it using FlexLayout later today. Thanks
from flexlayout.
Thank you so much. I'll wait for the FlexLayut example. I do not use PinLayout.
from flexlayout.
@sLm-s, here is the solution to your layout:
flex.addItem().direction(.row).padding(2, 6, 2, 6).backgroundColor(.cyan).define({ (flex) in
flex.addItem(redLabel)
flex.addItem(lineSeparator).height(3).grow(1).marginHorizontal(6).alignSelf(.center)
flex.addItem(purpleLabel)
})
from flexlayout.
@lucdion Thank you for helping me.
from flexlayout.
@lucdion Is it possible to change the width of an object, for example, if it was initially set to zero but after calculations 100. Excuse me for my obsession.
from flexlayout.
Yes, it should work if you do myView.flex.width(100)
and then relayout the flex container.
from flexlayout.
override init(frame: CGRect) {
super.init(frame: frame)
contentView.flex.addItem().direction(.row).paddingVertical(1).define({ (flex) in
flex.addItem(imageStar1).width(widthStar).marginLeft(1)
flex.addItem(imageStar2).width(widthStar).marginLeft(1)
flex.addItem(imageStar3).width(widthStar).marginLeft(1)
flex.addItem(imageStar4).width(widthStar).marginLeft(1)
flex.addItem(imageStar5).width(widthStar).marginLeft(1)
flex.addItem(fonLineView).height(heightLine).grow(1).marginHorizontal(8).alignSelf(.center).define({ (flex) in
flex.addItem(lineView).grow(1)
})
flex.addItem(countMark).width(25)
})
}
But then I want to install lineView.width = 100
lineView.flex.width(100) this does not work
lineView.frame.size.width = 100 it works
from flexlayout.
Setting directly lineView.frame.size.width
will work until the flex container will be relayouted by contentView.flex.layout()
. After lineView.flex.width(100)
(you may have to call lineView.flex.markAsDirty()
too, I'm not sure) you must relayout the flex container using contentView.flex.layout()
.
from flexlayout.
@lucdion Thank you so much. It works.
lineView.flex.width(width)
contentView.flex.layout()
from flexlayout.
There is one more problem. FlexLayout incorrectly determines the size of the button.
And if there is a lot of text in the button, it does not change in size.
lazy var button: UIButton = {
let button = UIButton(type: .system)
button.contentHorizontalAlignment = .left
button.sizeThatFits(.zero)
button.titleLabel?.textColor = UIColor.black
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
button.titleLabel?.lineBreakMode = .byTruncatingTail
button.titleLabel?.numberOfLines = 0
return button
}()
let label: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.systemFont(ofSize: 14)
return label
}()
from flexlayout.
I cannot fix the error
Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2: /Users/slm/Documents/Project/Flip/Carthage/Build/iOS/FlexLayout.framework/Modules/FlexLayout.swiftmodule/x86_64.swiftmodule
*** Building scheme "FlexLayout" in FlexLayout.xcodeproj Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/slm/Documents/Project/Flip/Carthage/Checkouts/FlexLayout/FlexLayout.xcodeproj -scheme FlexLayout -configuration Release -derivedDataPath /Users/slm/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B55/FlexLayout/1.1.5 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath ./ SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO (launched in /Users/slm/Documents/Project/Flip/Carthage/Checkouts/FlexLayout)
This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/0_/r8ll6bnx44g68llzb22frp_c0000gn/T/carthage-xcodebuild.53dsTj.log
from flexlayout.
@sLm-s I have fixed the carthage compilation, sorry for that. I'll check your other problem.
from flexlayout.
@sLm-s for your button issue. It looks like the UIButton sizeThatFits always returns an height matching one text line. If you call this line in layoutSubviews
let size = button.sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))
The size.height is always the same value, even if the text is longer.
It looks like if you want to have a button with a multiline label, you'll have to subclass UIButton and implement the sizeThatFit method.
from flexlayout.
@lucdion Thank you for your help and your work.
from flexlayout.
Hi @lucdion. Whether it is possible to make the fixed size of the container, and the FlexLayout calculated the size of all objects this container ?
from flexlayout.
Other question: whether it is possible to make the container transparent and in it objects not transparent. Or create transparent background for a container
from flexlayout.
The container can be transparent by setting its background to UIColor.clear.
I'm not sure to understand your question related to "fixed size of the container", can you rephrase it?
from flexlayout.
Here is an approximate problem.
from flexlayout.
Hi @lucdion . Is it possible to determine the coordinates of the object inside the container FlexLayout ?
from flexlayout.
If you keep a reference on your object (view), you can always retrieve its frame
property after the container has been layouted (ex: myView.frame.origin.x
, myView.frame.origin.y
)
from flexlayout.
For tips for UICollectionView, you can check how this has been achieved in the UICollectionView sample.
from flexlayout.
How to be if you need a specific size and not objects inside the cell. For example, the height is 320 and the height of all objects is 280 then I need these objects to stretch to the entire height of the cell 320 more precisely those that can for example UILabel
from flexlayout.
Created shoot there are several kinds of collections placed in it. If the turning screen fires the Villtransition method. But the problem is when you return to the previous screen the layout changes its dimensions in your eyes and it doesn't look very nice.
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)coordinator.animate(alongsideTransition: { (context) in self.layout() }) { (completed) in } }
from flexlayout.
@sLm-s to stretch items you must specify the grow value for at least one of the container's children. For example, if you specify a grow value for all container's children, the available space will be equally distributed. By default the grow value is 0, which don't expand.
Sometimes you also need to specify the shrink
value if the container is smaller than its children size.
from flexlayout.
@lucdion Unfortunately this does not help. Here are the screenshots.
I open the application the first screen appears, I rotate the in landscape. And I turn to a new screen, then I turn over to the portrait view and go back. After this, the calculation of the layout is not correct. But the second passes and the layout takes a normal form.
And the most incomprehensible moment for the first time works normally
from flexlayout.
Your FlexLayout helps me very cool. One problem a lot of questions)). I'm not an experienced yet developer((.
from flexlayout.
Hi @sLm-s, could you share me your whole project, or at least extract those screens that have issues. I could look at it.
from flexlayout.
I do not even know how to show you the part of the project so you can understand it and. I filled in the code in which I create a layout with the help of UIScrollView. There are several types of UICollectionView in it. When I click on a cell, I switch to the same controller but with a different layout. And when I start to rotate the screen the layout is well updated but if I go back to the previous controller then the layout is not updated normally. Sorry for my bad English
UIscrollView I use because it has a smooth scrolling
from flexlayout.
@sLm-s if you completely comment the code in viewWillTransition
in ScrollCatalog, and simply depend on the viewDidLayoutSubviews
method, does it work correctly?
Also to clean up a little bit your layouting code, you should probably move all your layout code from viewDidLayoutSubviews
into your layout
method. This way all layout related code would be at a single place.
from flexlayout.
In viewWillTransition uses only layout() the rest is not important
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)
coordinator.animate(alongsideTransition: { [weak self] (context) in
guard let strongSelf = self else { return }
strongSelf.layout()
}) { (completed) in
}
}
from flexlayout.
In viewDidLayoutSubviews looks like this. the rest are additional chips
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
scrollView.frame = view.frame
rootFlexContainer.frame.size.width = view.frame.width
rootFlexContainer.flex.layout(mode: .adjustHeight)
scrollView.contentSize = rootFlexContainer.frame.size
}
}
}
from flexlayout.
In file parsScrollCatalog.swift created the whole layout
from flexlayout.
viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
Does not work for layout recalculation?
from flexlayout.
Hi @lucdion . Thank you for your help. I figured out why the layout was not working correctly. I apologize for the stupid questions. I'm just learning, very little experience.
from flexlayout.
No problem, happy to try to help you!
from flexlayout.
Related Issues (20)
- 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.
- Xcode15 crash HOT 1
- UITextView cannot be edited 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 flexlayout.