Post

Replies

Boosts

Views

Activity

Positioning UITabBarItem's image
I want to position the image of a UITabBarItem with the imageInsets Property, but whenever I use a SystemItem or an SFSymbol as UIImage it doesn't work. Contrary to this a normal custom image works just fine and I tried it in code and with the storyboard. So my problem is that the position of some SFSymbols is not properly centred, is there a way to fix this?
7
0
4.4k
Feb ’21
How to push a ViewController as a Popover
As the title suggests, I would like to push a ViewController onto the navigation stack, not full screen but as a popover, but despite setting the modalPresentationStyle to .popover at various positions I can't get it to work, it is still presented in full screen. If I use present(vc, ani, comp) it works, but not with pushing. For clarity, it should look like the iOS Clock or Calendar app, when you add an alarm or create a new event.
2
0
7.4k
Aug ’20
Push ViewController as Popover
As the title suggests, I would like to push a ViewController onto the navigation stack, not full screen but as a popover, but despite setting the modalPresentationStyle to .popover at various positions I can't get it to work, it is still presented in full screen. I the end it should be like in the Clock App, when you add an alarm.
0
0
336
Aug ’20
Class hierarchy or not ?
Hello everyone,I got a question and here is a little example to demonstrate it.Lets suppose I got a class Soldier which has some typical attributes.class Soldier { var healthPoints: Int var attack: Int var defense: Int var type: SoldierType...}enum SoldierType { case ARCHER case INFANTRY case CAVALARY}Now I want to use several soldier types with different default values therefore I have two ideas:1. Subclassing the Soldier class and then providing an initializer for each type of soldier I want.e.g.class Archer: Soldier { init() { super.init() healtPoints = 100 attack = 10 defense = 2 type = .ARCHER }}...2. My second approach would be to initialize the Soldier with a type and then switch the type.init(type: SoldierType) { self.type = type switch type { case .ARCHER: healtPoints = 100 attack = 10 defense = 2 ...}I hope Iam not on a completly wrong path.If not, I would prefer the first option,but since Swift has no access modifier for the class and subclasses only, I would have to make everything private and provide setter, which I really do not like.If there are other better ways, I would be glad if you let me know.Thanks in advanceChris
9
0
711
May ’20