Building the iOS Project framework

Source: Internet
Author: User

Haven't written a blog for a long time, recently learning Swift, ready to write a project with Swift, find AppStore, find a called Half sugar project, look at the interface is really good, but feel the technology can't keep up, try to write it first

File into a folder,

Open the folder, find payload, open, and then right-click to display the contents of the package, and then you will see a lot of resource files, but you will find that you can not find Tabbar pictures, today to introduce you a powerful tool https://github.com/devcxm/ Ios-images-extractor, on Git search under

You will have unexpected surprises oh, download it down and run it directly. xcworkspace file

After running, directly drag the IPA file into, and then click Start, when finished click Qutput dir will be able to see all the resources, is not very good!

Well, the preparation is done, now we start building the project, opening the Xode, creating a new project, choosing Swift

Then set the adaptation target at 7.0, not the screen

Then in the resource file to find the icon, and Lanuchimage,icon found 3, I put 2, remember by the size put Ah, in the Assets.xcassets file a new launchimage, also remember to change the general set

The lanuchimage in the found resource file is then placed by size

Run the result, is not very good, the icon has changed over

Next, the project classification to build, this time I am ready to write pure code, so now the storyboard file deleted, the system automatically generated Viewcontroller also deleted, modify the general settings

Create a new folder under the project folder so that it is easy to manage, because if you newgroup directly in the project, the new group is virtual and not easy to manage

This is my classification, in 5 tab folder, there are 3 folders, Model,view,controller folder, using MVC mode

Project structure

I looked under, this project does not have the guide diagram, so first will Tabbar resources import, remember must put in @2x position, I put in the first position, pit dead me,

Inherit Uitabbarcontroller create Bttabcontroller and create a 5 tab controller,

Bttabcontroller code is as follows, because only the picture, no text, so to set the tab ImageSet property

Import UIKitclassBttabcontroller:uitabbarcontroller {Overridefunc viewdidload () {super.viewdidload () Self.view.backgroundColor=Uicolor.whitecolor () Bulidview ()}Privatefunc Bulidview () {Let Imagearray= ["Tab_ Home","Tab_ Community","Tab_publish_add","tab_ Classification","tab_ me."] Let Selectimagearray= ["Tab_ Home _pressed","Tab_ Community _pressed","tab_publish_add_pressed","tab_ Classification _pressed","tab_ my _pressed."] Let Viewnamearray=[Homeviewcontroller (), Communityviewcontroller (), Addviewcontroller (), Classifyviewcontroller (), Mineviewcontroller ()] forIinch 0.. <imagearray.count{Let Ctrl=viewnamearray[i] Let tab= Uitabbaritem (Title:nil, Image:uiimage (Named:imagearray[i])?. Imagewithrenderingmode (. alwaysoriginal), Selectedimage:uiimage (Named:selectimagearray[i])?. Imagewithrenderingmode (. alwaysoriginal)) Tab.imageinsets= Uiedgeinsets (top:5, left:0, Bottom:-5, right:0) Ctrl.tabbaritem=Tab Let Nav=Uinavigationcontroller (Rootviewcontroller:ctrl) Addchildviewcontroller (NAV)}} OverrideFunc Preferredstatusbarstyle ()Uistatusbarstyle {return . Lightcontent}Overridefunc didreceivememorywarning () {super.didreceivememorywarning ()}}

Appdelegata code, and the common folder

Import UIKit  public Let screenwidth:cgfloat = uiscreen.mainscreen (). Bounds.size.width publicly let Screenheight:cgfloat = uiscreen.mainscreen (). Bounds.size.height public Let Screenbounds:cgrect = Uiscreen.mainscreen (). Bounds

Import Uikit@uiapplicationmainclassAppdelegate:uiresponder, uiapplicationdelegate {var window:uiwindow?func Application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [nsobject:anyobject]< /c3>?) -Bool {Self.window?. BackgroundColor =uicolor.whitecolor () window=UIWindow (frame:screenbounds) window!. makekeyandvisible ()//set the status of the global navigation barUinavigationbar.appearance (). Tintcolor =Uicolor.whitecolor () uinavigationbar.appearance (). Bartintcolor= Uicolor (colorliteralred:228/255, Green: $/255, Blue: $/255, Alpha:1.0) Bulidmaincontroller ()return true    }    Privatefunc Bulidmaincontroller () {window?. Rootviewcontroller =Bttabcontroller ()} func applicationwillresignactive (application:uiapplication) {} func app Licationdidenterbackground (application:uiapplication) {} func applicationwillenterforeground (application: uiapplication) {} func applicationdidbecomeactive (application:uiapplication) {} func Applic Ationwillterminate (application:uiapplication) {}}

Modify the status bar color

End the run effect as follows

Perfect, completed the beginning of the first part of the only need to complete the code in 5 tab in the line, today wrote here Ah, a little tired ah ... tomorrow try to write the first interface, looked at, quite complex, estimated to GG

Building the iOS Project framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.