|
|
|
This is challenge three of project three. struct flagImage:View{ var a:String var body:some View{ Image(a) .renderingMode(.original) .shadow(color:.purple,radius:50) .overlay(Rectangle().stroke(Color.black,lineWidth:2)) .clipShape(RoundedRectangle(cornerRadius: /@START_MENU_TOKEN@/25.0/@END_MENU_TOKEN@/))
} //call the struct flagImage(a: // the name of the image) I finished the project three. Thanks,again. |
|
I design a game of rock,scissor,and paper,however,it differs with the requirement of Paul's,but I think it is my first design authentically,so I share with everybody. May it is not so good,I love it at least,that's enough. import SwiftUI struct ContentView: View { //2.make an array of String,and we need it refreshes after end every time. @State var gamechoice=["✊","✂️","👋"].shuffled() //3.产生一个随机数 @State var number = Int.random(in:0...2) @State var click1=true @State var click2=true @State var click3=true //4.刷新数组和序号 func gameagain(){ gamechoice.shuffle() number=Int.random(in:0...2) } func result1()->String{ if gamechoice[number]=="✊"{ return "👋"
} struct myview:ViewModifier{ func body(content: Content) -> some View { content .font(.title) .frame(width: 80, height: 30, alignment: /@START_MENU_TOKEN@/.center/@END_MENU_TOKEN@/) .padding() .foregroundColor(.black) .background(Color.green) .clipShape(RoundedRectangle(cornerRadius:20)) } } extension View{ func usemyview()->some View{ self.modifier(myview()) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts! Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
I have finished the project four,but I need to conclude it,for the reason that Core ML(Machine Learning) is very difficult. Actually,I think that most of us need review what we have learned frequently,I always forget how to use some modifier,how to create a view,and how to write the syntax of the nil coalescing so on. I will continue studying,only persist can we become a real ios developer. |
|
I have finished the project five,but I still need to do it's chapter of wrapup and challenge. In the process,I gain one person's help,thank you again. And the next days,I will go on! My first goal is that I want to buy a MacBook(Pro is fine) with the first salary as an ios developer! Thanks everyone here! |
|
Recent days,my study state is not as good as last weeks,I am trying to adjust myself to accept some failures from study and life that has a negative effect on me. Today,I will finish project 6! Go! |
|
I have finished the project 6,however,I have also forgot it entirely. There are too many new things that I need to learn,too much knowledge that I need to review. Great haste is not always good speed. So I will devote my energy,time into it. |
|
I have finished the Consolidation project 4 to project 6 day. I met a lot of problems,so I listed them here.I just believe I could solve them one day in the future as I presist learning. Problems: First-----I don't know how to create a Question struct with SwiftUI. Second-------I don't know how to split up views,I put all my views in the ContentView. Third--------I don't understand the requirements of the project throughly,just is it a multiplication tables? If it is,why does it contain 1-12 rather than 1-9? Here is my code: // // ContentView.swift // Edutainment // // Created by 林锋 on 2021/4/17. // import SwiftUI struct ContentView: View { @State private var num=0 @State private var selectnum="" @State private var answernum="" @State private var numarray=[1,2,3,4,5,6,7,8,9,10,11,12] @State private var questionnumber=["5","10","20","All"] @State private var myselect=Int.random(in: 0...11)
}
struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } At last,whatever lever the project is,I finished it by myself. I will look at other's code for the project to improve my ability,refine the code and go on learning. As Paul said "this is a marathon,not a sprint".It is not important that how much works you finished in one day,instead how long you will insist. |
|
Hello,Everyone,I'm here again.Yes,I have finished project 7,including its three challenges. Those are my codes that were written by myself,of coures,they are useful. For the first challenge,it is so easy for me to do,what we need to do is that add some codes we have seen them in the privious chapters:
Second: I use different colors to describe how much we cost,if it is less than 10,its color is black,between 10 and 100,the color is orange,but more than 100,color is red,it is a signal that you spend too much! if a.pill<10{ Text("(a.pill)") .foregroundColor(.black) }else if a.pill<100{ Text("(a.pill)") .foregroundColor(.orange) }else{ Text("(a.pill)") .foregroundColor(.red)
third: I encounter one problem for this challenge,when I finished for the first time,I met a bug that when I put a data into cost amount with wrong type, the view won't dismiss any more after I clicked the Button of "完成". Fortunately,I solved it by myself,I 'm so proud of that. I just put the sentence------ "self.hide.wrappedValue.dismiss() " into the givevalue() method,however,it was in the navigationBarItem at the begining.
.navigationBarItems(trailing: Button("完成"){ givevalue() })
|
|
It is a long time for me to upload my study records,because I found a job in last days,it is a big challenge for me to work as side as go on learning,I will stick to it. This morning,I am going to be finishing project 8 day three,come on! |
|
I have finished project 8, however,what I need to do is that to finish its wrap up and challenge. I forgot everthing I have learned,what a pity! I need to do some conclusions that will help me reminder some knowledge. And follwing days,I will have three days for vacation,my goal is to finish project 9,and consolidation of project7 to project 9. When I finish that,I will post my process here. |
|
|
|
Hello,guys! I am now going to sharing my codes with you.Of course,if you have any idea,you can comment on this remarks. The first challenge is that we need to show the launch date below the mission badge,here is my codes: Text("(mymission.formattedLaunchDate)") to be honest,I don't remember how to write the code of date,it is difficult for me,but I will conclude that.And next post,I will answer the questiion. The second challenge is we need to show all missions that the astronaut had partipated: 1.I create a constant named allmissions,it's type is array of mission.It will storey all our missions.
2.here,I wirte two ForEach(),the first one aims to go through all the missions in our array,and the second aims to go through the crew of per mission,we can find the name of crew in the second ForEach(),so we can judge if the name of crew equals to the id of astronaut,if it is true,we just print the mission.
static let astronauts:[Astronaut]=Bundle.main.mydecode("astronauts.json") static let missions:[mission]=Bundle.main.mydecode("missions.json") static var previews: some View { SwiftUIView(thisastronaut:astronauts[0],allmissions: missions) } } NavigationLink(destination: SwiftUIView(thisastronaut: who.crewastronaut,allmissions:missions)) 3.the last one is that make a button to change the things that be shown: when I first write the code,I make a button,and the content of text view will be choosed between date and time,but I find that if I tap one item,the other items will also be changed.That seems bad,so I take a long time to solve the problem,of course,I made it. Button(action:{ show.toggle() show2=num
I created two properties,show and show2. the show property aims to change the contents,the show2 aims to decide which one will be changed. I give the num to show2,when you tap the item. |
|
Sorry,I just played games for three days,it is so funny. Go! I will post all my study here,whatever I did. |
|
|
|
I have finished project 9. What I need to do is that finish the challenge and wrap up. And I will take this week to conclude from project 7 to project 9. Next monday,I will begin to study project 10. I swear I will finish all these projects,and find a job as a junior ios developer. |
|
I have finished reviewing and concluding part one and two of project 9. Tomorrow,I will finish to conclude all of project 9. And I will upload my process everyday. |
|
Here is my answer for three challenges of project 9! Share with you ! Hopefullly,I look forward to your reply. // // ContentView.swift // challenge9.3 // // Created by 林锋 on 2021/5/21. // import SwiftUI struct ContentView: View { @State private var myamount=0.5 @State private var mynum=100.0
} struct colorcyclerectangle:View{ var amount=0.0 var num=100
} struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } This is the third challenge. The following code is the first and second. // // ContentView.swift // Challenge9 // // Created by 林锋 on 2021/5/20. // import SwiftUI struct ContentView: View {
} struct arrow:Shape{
} struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } |
|
I finished the challenge of the conclusionof from project 7 to project 9. Generaly speakinng, it is significantly easy.Beacause all the functions we bulit that we can refer to project 7----IExpense. I hope you guys also feel good for it. Of course,I met one problem,it is hard to explain clearly with some sentences,so I will contiue to solve it by myself. One new api I learned is Timer() modifier. Tommorow,I should begin to learn Project 10. |
|
Project 10 hello,guys,I am so please to see you here again! And I have a lot of things to share with you.May be three! The first thing I want tell you is that I have finished the challenges of project 10,of course,I have learned a ton of things.To be honest,I am now more interesting in Swift and SwiftUI through the learning of this project,it shows me many things such as what the URL is,how to encode and decode @Published properties,how to check the network resort of the third party manager,etc. the first challenge:how do we ensure whether a string is valid when it is whitespace? we should write a extension for String like this:
When a parameter is type of String with all whitespace, we use parameter.isspace to judge,if it is whitespace,the value is true. the second challenge:how do we check the status of our phones' network?Here,we should leverage the third dependency manager:Reachability!
I really have a deeper comprehension for Swift is more like a kind of natural language by through this dependency manager,and this is also the reason why I don't provide any annotations for the code that it is so clear to be read and understood. And the biggest problem of the process of using it is how to import it,I had took much time to solve the problem.Image is better than text,please look at the following pictures: Firstly,drag the Reachability project into your aimmed project: Secondly,add Reachability.framework to the setting. Last,you should write "import Reachability" before you use it. Unfortunately,I can't introduce image,sorry.But you can search it online. the last one: the conbination of struct and class with @Published,I want to say that this actually is a simple test for you,me and everyone.
I don't know whether you have noticed that there is a bug in our porject 10,however,it isn't the false of codes but the design.If you think about it more,you will find when we order different cupcakes it can't be achieved,you have to order the same type cupcakes. So I rebuild it like this:
At last,I want to tell myself that remember to review ,conclude and go on! |
|
Project 11. Yeap,I am always here.Those days I find that I can grasp the tutorials more and more easier than before.Concerned my speed is increasingly fast,I decide to stop to review project 10 and 11 for the reason that there must be lots of things are worthy me reviewing. Ok,here are three challenges as usual I share them with you : First,fix the bug that there is no picture when we don't make choice.But I want to explain why it appears in our project though there is no wrong in our codes.At beginning,we set the default value of genre as "",however,the default value of rating is "3",so you can see that even you make no choice on rating,it has a default choice that is three.Does genre has a default choice? yes,"" is its choice,wheares we don't have a picture that named "",so there is nothing. About solutions,we have two ways: 1.change the default value of genre to any kind of names in our array,such as :Kids,Rommance.
''' 2.As we all know,the value of book.genre is an optional value though it is different with Swift's optional value, we can provide it with a value as default when we try to unwrap it.
Second,modify the book.title as red color when its rating is under one star.We can use a condition like this:
last,add date for our books. 1.add attribute. 2.add a datePicker,then give the value to book.date property. 3.show it with a custom format like in Moonshoot project.
Actually,the third one is not perfect,I feel no comfort for it,I wish I can modify it in the following oneday.`` |
|
Project 12 Ok,congratulate to myself for I have finished project12.My god,I feel it has many things we need to learn,though the grade of its difficulty is medium,so I want to conclude and share with you. I want to begin with its three challenges: Here are my codes:
It works well except one problem. As you can see,we have two parameters in "init(){}",one is an array of NSSortDescriptor,another is string of "Predicate".In the ContentView
I need your help. Thanks.
If I use syntax of number 1,when I run the app,if I click add button then app crashed.Here are reporting information: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Can't do a substring operation with something that isn't a string (lhs = 123 rhs = 6)' terminating with uncaught exception of type NSException if I use syntax of number 2,of course,I modify the "init(){}" to the right way,everything works well.So I have to use syntax of number 2 to add some data for test,after that I replce it with syntax of number 1,of course,what I still cannot do is click the add button. |
|
Milestone 10 to 12. Remember to create the names of transformer and custom class by yourself.For example,as shown in the following picture: Even I look at the tutorial,I can't send a picture off the website.Who can tell me how to send a local image to the website??????? |
|
Project 13. First,I finished a new project again,there are lots of new things we need to learn in the project for me a jackroo of UIKit.I want to summary it simply what I still remember now. (1)What are differences among @State,@Binding,and Binding<T> ? I say that when we use parameter in different views,we should use @Binding, instead we use @State and Binding<T> when properties are in the same view,like ContentView.Of course,they have many differences in essence. (2)actionsheet is almostly as same as sheet and alert.It slides up from the bottom of the screen,and includes title,message,and an array of buttons,such as cancel(),default(),destructive(). (3)UIImagePickerController,this is a new thing for me,however,as soon as we can hold the logical core,it won't be a big challenge for us. (4)Different filters in CoreImage.What we need to remember deeply is that the relationship among User's Image,swiftUI image,UIImage,CIImage and CGImage.One of the most important thing is we'd best to create context only one,because it is expensive. (5)Coordinator and delegate. (6)UIImageWriteToSavedPhotoLibrary. (7)How to change filter dynamically? (8)How to check inputkeys of one filter? OK,the next is my codes to three challenges,and there is no difficulty: ---If there is no picture in the gray rectangle when we click the save button,there should be post an error.Actually,the best way is to show an alert.But here,I plan to print something like this:
yes,I change the type of image to UIImage?, and make sure it is not nil before we go on the program. -----make the button that we can choose different filter when we click it show the name of the current filter we are using.It just we create a @State string property,and give the filters'names to it.
-------add a slider,use it to control our radius input keys.
That is all,I wanna say remember to make sure if a picture has been shown before we change and ,save it. |
|
Project 14. Yep,I finished this project by tooking much time and energy,I just wanna say it is the hardest project we have met so far.There are many things are unfamiliar to us,like MKPointAnnotation,MKAnnotation,MapView,they confused me a lot.I found,however if you can look at it repeatly you will find you gradually grasp all of them,maybe not as difficult as begin. Ok,let me have a review and conclude for some problems that I met in my learning progress. Have you get the hang of thoes skills? (1)Override operator.This is may familiar to you if you had learned C++,there is a difference that the methond name called "<" less than,if we wanna get an array with ascending sequence,we don't have an equivalent called “>”in swift,we need to filp the return of the less than method,or change the closure.Do you still remember "="? What is its overriding form? (2)Write to your document directory.This is very clearly,firstly we need find the path;second,adding a file name to the url;third,we should use some method to finish it,futhermore,the encoding of data is very important. (3)Face id and Touch id.This is a action relates to user's privacy,so we should take it seriously.It has some following steps: import LocalAuthentication, add"Privacy-user FaceId description" in Info.plist,its function to explain to user why we want to use Face id or Touch id,of course,this statement is for Face id specially. Last,with some method we can achieve it,".canEvaluatePolicy",".evaluatePolicy",you should remember you can't put the first method in the second that will caues deadblock. On,one more important,we define a varitety named error,the type of it is "NSError?",I guess it is very weird to you,it is Objective-C object,and when you use it remember to add "&" before it.It is almost as same as a operator that gets one's address in C++. (4)MapView.When we wanna import an empty map in our app,we should create a struct conforms to the "UIViewRepresentable" protocol.What I wanna to intense is when you use code completion in Xcode12 and Swift 5.0,you should find this---
you should change "some UIView" "UIViewType" to "MKMapView",otherwise you can't use ".annotation" because they don't have a member of "annotation". (5)Coordinator.In different context it has different type,like project 13 and 14,it conforms to different protocol,but the concept is similar that acts as the delegate of UIView. (6)MKPointAnnotation.It conforms to MKAnnotation,we can create a instance of it,which has many properties,such as title,subtitle,coordinate.Besides,we can use MKPinAnnotaionView() to customize our view. Ok,I have a heck of a lot of things to write here,but I decide to talk with myself.So,here is the three challenges: (1)What is the difference when we give all the modifiers to Image or give them to the Button? There is actually no distinguish on the appearance,but the function changes a lot.When those modifiers belong to Image,we can tap everywhere of the circle button,insteadly we must click precisely on the "+" symbol then it can work when those modifiers belong to Button. (2)Rewrite Mapview,Circle,Button.When you finish it,your codes should like this:
It is more clearly than it was.We just need to pass some parameters into the Button,Circel,Map. (3)When error occurs during our biometric authentication we should present an alert.The following codes work well:
That is all,I hope I can continue to learn, review again and again. |
|
Project 15 Last days I lost all my data on my disk on the reason that I remake my computer's system,forgeted to back up. If I want to follow the process of project 15,I have to rebuild project 2,7,and others,it will take much my time,and my primary task is to finish the swiftUI 100 days,so I just leave it for some days,I will complete it when I begin to review all the projects for the sencond time. Maybe it will at september. |
|
Milestone project 13 to 15 I spend four days making the challenge,but I don't know how to share my working with you because it contains four subviews.Maybe you can contact with me through my QQ,1092908676. And I can tell you one thing,if you wanna change our annotation's style when you drop a pin on the map,like an image,here is the method that you should use as same as usual:
And I met a problem,which looks very simple but is cunning:
Can you differ their differences? Tonight,I will begin to learn project16,of course,as the following days I will review the project 14,at that time will make this challenge to be perfect. |
|
Project 16 ! Hey,guys,I have finished project 16.Again,I come here to share my feeling with you about the whole learning process.As we all know,all the contens of the project are about swiftUI pure,so it is not as hard as other projects,though there are many things we need to remember. I wanna make a simple conclusion and review: (1)@EnvironmentObject,we should send one with".environmentObject(xxx)" firstly,then accept it with "@EnvironmentObject".Attention,if you send one to environment,you must accept it,otherwise,your codes crash. (2)objectWillChange,it should be used at class's properties. (3)TabView is the parent view,its priority is older than navigationview.We can add "tabItem","tag" attributes. (4)Result type.The form of it is really unfamiliar to us,maybe we need to practice more. (5)ImageInterpolation,its function is it can smooth the image when you scale it up.It has many types,such as ".none",".small",".medium".The first one is we usually use. (6)context menu,you can use it below any views,".contextMenu{}",in the closure you can add as many buttons as you want. (7)local notification.First,we should create an instance of UNNotificationCenter.current(),second,add request and post request.Last,remember to ask for permission. (8)import third party dependencies.I understand the meaning of number of vision,like"11.2.1",11 is major number,2 is minor nuber,1 is patch number.This aslo explain one problem why I fail to update my computer system vision from 10.15.7 to 11..2.1,because major number has been changed,that means some API had been broken. OK,there are still many things we can learn by observe carefully, but here is enough.And the following codes are for three challenges of this project: (1)add an icon.I download a software from the internet,it is called SF Symbol.It contains all SF Symbol of Apple,you can use it to search what you want.I choose "people.crop.circle.checkmark","people.crop.circle.exclam",and the color of icon will be changed by wether this perosn has been contacted,between red and green.
(2)Use JSON and the documents directory for saving and loading our user data.You should commnent out your codes of "UserDefault" saving before you write some codes,because you will not discover any problems if you make wrong,after all,your original codes work well.Actually,this is easy,what you need to do is make your class be Codable.
first,you should make the class be codable,because the "personarrary" is "Published",which can't be decoded or encoded,we should write "enum","required init(){}","func encode(){}"by ourselves. second,we should write a new method of saving,with FileManager. third,for the initialization of the class, you should read data from where you save them. last,we should rewirte the property-----personarrary,because it shoul be read and write freely. (3)Use an action sheet to customize the way users are sorted in each screen – by name or by most recent. I believe that you can write some codes for achieving actionsheet easily,but the sort may take your some time.OK,here is code:
This is first step of my work,add "Comparable" protocal,wirte sorted method,but do you noticed what I have added? Yes,"static var sequence="" ",it belongs the calss person rather than an instance of it. And I give it two values "name" and "date",which is our base of sorting. Still,"var date=Date()",with it in place,we can sort with date.Next is actionSheet codes:
I only need to give one value to sequence,which value depends on what we want to rely on to sort. That is all,I hope I can cotinue to learn,and prepare for my first app. |
|
|
|
|
|
Project 17 ! I am not happy with the completiom of the project,it confused me a lot especially challenge two.To be honest,all those knowledge of this project give me mor thinking,if you wanna build a great,fatalistic and excellent app,you need to take care of many things,but how I should do somehow I am just a jackaroo,all what you need to do is keep your confidence,hold your persistence,go on learning from trival learning. (1)Gesture.There are several types of gesture,what impressed me are TapGesture,DragGesture,and Sequence.If you have noticed that TapGesture and DragGesture,both of them have onChanged() and on Ended() modifiers,of course,TapGesture still has .scaleEffect(),instead DragGesture has .offset().By using Sequence modifier,we can combine different types of gesture to generate different effection. (2)UINotificationFeedbackGenerator() comes from UIKit,it is different with CoreHaptics. (3)allowHitTesting() very likes disable(),do you still remember that? The only difference between them is they will have opposite result with the same value,like true or false. (4)create a timer, the syntax is this sentence: var mytimer=Timer.publish(every: 1, on: .main, in: .common).autoconnect().We need to grasp what these parameters mean. Besides, I am very curious about one question:stop the timer and recreate it everytime,will that cause a problem of perfomance when we restart the game? (5)Different styles of NotificationCenter,we send kinds of them,and receive them.such as:UIApplication.willResignActiveNotification,UIApplication. willEnterForegroundNotification.But remember one special thing:VoiceOver is controled by "accessibilityEnabled" (6)Accessibility.Here are some kinds of common accessibilities,like accessibilityDiffrentiateWithoutColor,accessbilityReduceMotion,accessbilityReduceTransparency. In the process of implementation of the project,what the biggest harvest is that I totally understand the coordinator of the ios,its center is on the center of the screen,below the middle line the value of y coordinator is growing over the length,on the right of the y coordinator,the value of x is increasing over the direction.So,you should able to master how to calculate the location of every card. And,the following codes for three challenges: (1)when the timers runs out,I design the app to show an alert that will congratulate you or noftify you regrettably.Of course,in term of customized haptic,I just use what our teacher had showed us. Unfortunately,though all my code works well, there is one bad thing,I will tell you at last.
When the time is over or we answered all questions,then the alert will be shown,its contents depends on your result.Oh,I canceled the timer,and recreated it when we restart our game.Will it cause a problem of perfomance as I asked you before? The use of customized haptic is easy,you can write all codes by referring to what we have been teached,there already has been one for us actually. (2)setting screen.To be honest,it tooks me much time rather than the code itself, I encountered a problem about the presentation of the alert and the screen when the last card is moved to the left to delete it only at the time.I found that the alert and the setting screen appeared at almost same time,but I can't see the alert because the setting screen is a sheet,it slided up from the bottom of the screen,so it covered the alert.And I don't know how to solve that in present,maybe I can solve it in the future. in CardView:
in ContentView:
in SettingView:
(3)we need to create a modifier to fix the problem of color.Do you remember how to create a custom modifier?I forget that at all.
I think what cause the problem is that the green is not pure green,it is modified by ios for more suitable and moderately for us to see.If I am right,I write a modifier,create a variable,its type is Bool,a roundedrectangle is as same as we built in the project,and change its color of fill to that.It is pure green,actually I don't find there is red in the process of when I move the card to the right with a distance that is not enougt to remove it,then release it,it will back to the original location. That is all,if I have made some mistakes,please tell you,thank you a lot. I plan to finish all the course before July,and commence on my first application----CWeather,hopefullly I can finish that. |
|
(1)MagnificationGesture() -----------scaleEffect() (2)RotationGesture()-----------------ratationEffect() (3)DrageGesture()------------------offset() |
|
Project 18! I just wanna share you with a special effect with GeometryReader.
Its effect is that in a vertical scrollview there are fifty circles,each one loactes in the middle,when you scroll,they will spin.You can have a try. I used Position() modifier to potion them with absolutely position. The remained three challenges will be finished in one day of the future,but I promise I will do that. I will stick to review ,learn and update! |
|
Milestone 16--18 This time I just share my app with you,actually it is very easy.I still need to try to vibrate my phone with another way----CoreHaptics,and show the possible value of the dice everytime we roll it with Dispatch.main.asyncafter(). Tommorrow I will do the remaining things,now, here is my code:
|
|
I didn't think more about the code,it is just a task for me,I know that it is a wrong attitude.
I understand the DispatchQueue.main.asyncAfter(),it will run the other code first,when it is come to the time we arranged,it will run the code in its closure. And CoreHaptics:
Ok,now I should continue to study the last project! |
|
Project 19! The last one project, the true beginning of the life of learing ios application development! Congratulate myself! This has showed my strong willpower and perseverance because I took totally three monthes finishing all the projects.Everyday I spend six hours,you can have a reference and arrange your time,plan properly. I found a bug in my app of milestone 16 to 18 project,everty time I roll the dice then the result will be saved to context,but the list of rendering all results will have a bad sequence,but only restart the app can the sequence be correct.It is so weird,I will try my best to fix it,wait for me! And these three challenges are so simple for me,here is code: (1) add a photo credit.I just place it on the line of country flag,it is a text,we only need to keep it default,the interface is fine.
(2)loading and saving methods:
The most important thing is this line of code,which I add an annotation. (3)user sort and filter.
I define a static variable,which type is string.It belongs to resort itself,not an instance of it.I leverage its different values to decide to which way of sorting we should use.As you can see,I use a switch syntax.
This is filter method,with three parameters:myresorts means all of our data;filterstand means which one is our stand of choosing,like country,price and size;filteritem means the specifical value of which country,how much,what is the size.
There are two buttons,one with one of ways of filtering,another with ".contextMenu". I found that if you use a "NavigationView",a "List" inside it, a "ForEach" inside List,a "NavigationLink" inside ForEach,you can't add ".navigationBarItem()" to NavigationVeiw,instead you can add it to NavigationLink. There is ending of our 100 days of swiftUI,but I will review it again,and still update what I learned. GO on! |
|
|
|
请问你可以把Project 9 的 Challenge 3 :control the position of the gradient using a property用Slider来呈现吗? 我看到你好像是用Button来呈现的,有没有可能用Slider呈现位置逐渐变化的过程? |
|
I have a try,and find it can be achieved.Here is my code,you can have reference. First,you should change the colorcyclingrectangle view to this,add four variables,they will be some position points that you can change.
Second, add some appropriate properites to contentView:like this:
As all changes done,you can change the position of the gradient with four sliders as you expected. |
TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.