Swift: setting different spaces between cells in CollectionView - swift

This might be something pretty obvious but I haven't been able to figure it out. I know how to set different sizes for each cell, and spaces between sections using UICollectionViewLayout. What about different spaces for each cell?
To give you a better idea I currently have:
and need it to look like this:
Any suggestions? Thanks in advance
[Edit] Ok the suggested link as possible duplicated solved my specific problem, but did not answer my question. In this case I wanted to center the the last cell. But what if I want the cell to be slightly more right or slightly more left? That's the actual problem I was trying to solve.

Related

How to create cells with different sizes using GridView in Flutter?

I want to create a similar view with Flutter as we can do it by creating a UICollectionViewLayout in iOS .
This is a sample code I am using.
https://github.com/flutter/flutter/blob/b8a2456737c9645e5f3d7210fba6267f7408486f/dev/integration_tests/flutter_gallery/lib/demo/material/grid_list_demo.dart
How to achieve this using GridView in Flutter. If not GridView, is there any other way to do it?
GridView is not designed to do this. You may be able to get a Wrap to do what you want, although from your example it may not quite do it (horizontally it definitely wont as it arrange the items into rows; vertically it might work for you or might not depending on exactly what you're doing).
If you're only ever going to have the two columns, you could simply have a Row containing two Columns and make sure to put the items in the right columns.
Or the more complicated but probably best answer would be to write the logic for arranging the items this way yourself - see CustomMultiChildLayout.
EDIT: there is also a package that may work for you. It can't do arbitrary sizing, and you need to know the sizes of the items in advance, but you can specify items to take up multiple rows or columns of the grid. See it here.
Note that if you have a lot of items, you'll probably want to do something with a CustomScrollView but that isn't really in the scope of this answer.
https://github.com/letsar/flutter_staggered_grid_view
This would help you. I think the plugin gives different size.

Best approach to displaying text

Xcode 8.3.2
As as newbie, I'm trying to get acquainted with segues, constraints, text fields and Image Views...mainly the design elements. I'm trying to put together a cheesy recipe book of favorite recipes. I wanted to know what's the best approach to display rich text with bold text and bullet points? Labels seem to be my only option but I was wondering if there were other options? Any advice would be appreciated.
ViewController in Storyboard
As much for my approach, during my career I learned that textViews (aka C# RichTextBoxes) can be pretty tricky..
You can go with classical UILabel approach with lines in Interface Builder set to 0 and atrributedText, which contains bullet points:
This is a nice tutorial, but a bit old and would probably do it another way, but I guess for the purposes is fine...
https://wingoodharry.wordpress.com/2016/04/10/bullet-point-list-ios-swift/
I would like to state here, that TextViews are the last option everywhere with text...
Wish happy coding! :)
UILabels are best way to display text, you can use attributedText in UILabels which will enhance your UI. Multiline text is a add on.
Else try using AsyncDisplayKit.

UITableViewCellStyleSubtitle text alignment

I made lot's of googling but found no solution :(
Is there any way to change the UITableViewCellStyleSubtitle text alignment?
it seems that you cannot change it,
I also had this same problem, and after a lot of googling i found that writing my own custom cell (that took me 10 minutes) was much more productive that doing further research
So my advice is, drop the search and start coding your own cell with subtitle
Yes, the only way for align-subtitle is to make your own custom cell class.

UIActionsSheet text shadow problem

I have a problem with the text shadow of the UIActionSheet buttons. At iOS 4.0.2 long string were truncated automatically. No at iOS 4.2 these texts are presented with a smaller font. But now the offset of the shadow is corrupted and to big.
Is there a possibility to change/remove the text shadow of the UIActionSheet.
EDIT: I'm building the UIActionSheet not with initWithTitle:, but with the normal init and sets all needed properties afterwards because the number of possible buttons is dynamic and the texts cannot be change. I've tested it with initWithTitle: and got the same results.
You can refer this to truncate your string before displaying it in a UIActionSheet.
I can think there are two workarounds for this (although I would not them myself in my application, reason listed below the workarounds):
In the first case you access the sublayers of UIActionSheet, get the labels, change the shadowOffset and shadowColor before presenting the actionsheet.
Secondly you can initialize the actionsheet with blank titles and add your own labels as subviews on the actionsheet at right places. (More tricky then the first approach).
Now the first approach is very risky as the layer structure of UIActionSheet can be changed by apple in future updates, hence your application may break and would not give good results.
Continuing with second approach is good only when you can calculate the exact frames where you should put your lebels so that they look good. But in your case the number of buttons would also vary, so this approach will take a lot of time initially to get the things working.
Hence, I would go for truncating the strings before I set them as the title of buttons.
Not sure how much would this help. But I am sure that truncating strings before setting them as titles is the best option.
are you doing anything non default for displaying the text?
If you only use UIActionSheet-initWithTitle:… you should write a bug report to Apple.
OR shorten the text to "Frankfurt International (FRA), DE" ;)
This appears to be fixed in 4.30. I found no way of fixing it in 4.2x.

subscripted letters in UITextField placeholder

I need to learn about ways of doing this. The options I am aware of are:
1) Load my own custom font which includes subscripted letters, or
2) Simulate a "placeholder" with two UILabels positioned directly over the UITextField, and make those labels go away when the user starts typing. In my case, this will be more work than it sounds like, because the whole thing will need to be data-driven.
Are there other options?
As best I can tell, the answer is "no".