Posts

Showing posts with the label constraints

RayWenderlich.com Layout in IOS Course - Part 6

Here we go! The final chapter. Possibly two entries but I may be able to do it in one. Then the Auto Layout is complete. As always I will do a consolidation entry. This chapter is all about constraints.  Start time - 13:35 Intro Attributes can be added - position, width and height Some of this is implied e.g. if you give the leading (left) and trailing (right) edges, then the width is derived from those Formulas are used to work out the position, width and height. Top and bottom Layout guide - keeps tab bars etc. separate. Stack views are usually the best way to set up views but constraints still needed. Add New Constraints So some cool shortcuts - add multiple heights/weights in one go. Do the whole make same height feature, based on one constraint already in. Minimum font scales - great if text is too big, then it will work on multiple devices. Drag Constraints Ok, so selecting options in the attributes - in this case centre horizontally and vertically ...

RayWenderlich.com Layout in IOS Course - Part 5

Image
It's been a while but for god reason! I've got a promotion at work, which means I've really got my future set. However, I am not going to abandon Swift. My work over the past 20-ish months has been rewarding and to let all of that go would be a shame. True, had I not got the promotion, I would probably be gravitating towards Swift more with an aim to transition to a career in the future. Anyway, that COULD still happen but it does make me want to rethink my goals a bit. We're also on an early holiday, so plenty of time to code and do a reflective entry of where I am and where I want to be. That will happen soon! For now, let's get on with the auto layout course! Start Time - 9:42 Intrinsic Content Size So this is the size that will fit EXACTLY into a a view's content. Content Hugging and Compression Resistance - these are rules that show the importance of contents not shrinking or resizing, bigger than the intrinsic size. 4 priority values to set. Vert...

RayWenderlich.com Layout in IOS Course - Part 4

Image
Here we go! So the course is split into Swift UKit. Interface builder. Let's do this! Start Time - 20:32 Introduction About half an hour tonight I reckon. Translates masks into constraints - apparently this is the option to use. So the whole point of Auto Layout is so you can fit onto any device. Stack views are coming here too. Autoresizing Fixed attribute will not change. OK, a key point here is that the content is all on an older Xcode - Xcode 11. So the features are all quite different. Trying to follow along still! Ok, can't even find size inspector! No point doing this on this earlier version of Xcode. So skimming through instead. I get the concept of all of this. The use of constraints etc. Autoresizing mask - flexibilities. All of the different options! Stack Views OK I've found some of the main views again! Out of practice with Swift UIKit! Stack view is non-rendering. That means non visible. Not even a background. Spacing is an attr...

Ray Wenderlich Course - SwiftUI (Part 4)

Image
Lots going on at the moment but I am going to squeeze in a session today. Next bit of SwiftUI! Start Time - 19:32 Second Section: Building Interfaces with Container Views So stacks in detail and using bits from Swift UIKit. Tab views coming up as well. HStack, VStack and ZStack A mention of alignments - leading is left and trailing is right. Different alignments to the centre default - first/last baseline alignment ZStack is different - you have elements on top of one another. So the whole right click and embed in V or H Stack means that this puts what you have within another stack. Makes sense. Here is what we have at the moment.... VStack {         HStack {                          Image ( "CatOnKeyboard" )                 . resizable ()                 . frame (width: 50 , height: 50 ) ...

Treehouse Intermediate Course - Part 7 (Generics 5)

Image
The roll continues! So I will do similar to the other week - do several entries within one blog as it may be a bit stop-start. I've got around 20 minutes now just to make a start. By the end of today I will be finished with generics! I will then do a follow up consolidation entry with extra practice before moving on! Start Time - 12:53 Associated Types Can protocols be made generic? It is already in the sense that any type can conform to a protocol. But what about the internal? As in the code that goes behind the scenes... Stack - a bit like an array but more limited. The main point is the order - last in, first out. That makes sense. Associated type for the function - you can use a placeholder name for the type that is used in the protocol. The actual type is not specified until we actually adopt the protocol. Here is the protocol - protocol Stack {          associatedtype Element          mutating func push...

Treehouse Intermediate Course - Part 5 (Generics 3)

Image
So to save the strain on my eyes, I am going to do several shorter entries today but put them into this one blog. It seems silly to have shorter entries which are all about the same content! Last time, generics was tough. But it was useful stuff! The challenge was tricky and so was the content; I'm going to continue with the current course, then do extra reading wherever necessary. Start Time - 09:55 Class Based Type Constraints So Pasan states that the example is 'trivial'...doesn't bode well! class Shape {}          func centre<T: Shape >(of shape: T ) {      print ( "Called" )     } let testShape = Shape () centre (of: testShape ) So just an example here of creating a class and then declaring the type within the <T: Shape> bit.  It works with inheritance too - if I created a  subclass of Shape it would work.  func centreOf( _ shape: Shape ) {     print...

*Xcode Project Entry 3* Times Tables Quiz - Part 2

Image
Five days with no Swift but I'm back! Recently I've been getting much more into exercise - gym, tennis, yoga...all that is good for the mind and body but I haven't got that 'bug' to really work at the coding. This is not good! Though it may also just be temporary. So nothing to worry about basically; I need to focus on this own project and get that done - it will be cool to have something completed that I can then put onto the phone etc. THEN I will resume Angela's course - that is something I will definitely be doing next. OK time to crack on! Start time - 18:24 Last time, all I did was to make the 'to do' lists. These are always essential for any project. Let's get started by setting up all of the labels etc. Before that - here are all the 'view' items (from MVC) from last time: \ So let's get all of this done! *First thing is to get an image for the background. I remember that I need to generate this for the x2 and x3 quality...

Angela Yu Xcode 12 Course - Part 10 (lectures 113 to 131)

Image
Right so next project! This was one of my favourite ones from before as there was a lot of logic but it was all very accessible too. With this idea, I could make limitless options and stories. Anyway, let's go! Start Time - 18:19 Right so that's the basic look of the app. And there's the decision tree for all the possibilities. Makes sense. OK project file downloaded! Next bit - tag values of the two buttons. Yes there are two options each time. Right, after some fiddly code, here's what I have - if sender. tag == 1 && storyIndex == 1 {             storyTextView . text = story3             topButton . setTitle ( answer3a , for: . normal )             bottomButton . setTitle ( answer3b , for: . normal )             storyIndex = 3                      } else if sender...