swift--Start Page internationalization: Load the start page picture dynamically, load the text when you start

Source: Internet
Author: User

Because of the company's needs, the request to do an international start page, because the app I also made internationalization, the remaining start page internationalization is not completed, Baidu Ah Google a lot of answers are not satisfactory, and finally see colleagues to complete, I also asked the specific approach, decided to share to the needs of people, lest and I was as anxious, Waste half a day, I realize the effect is either the Chinese version of the display is normal, the English version is not normal, either the Chinese version of the text display Chinese, or the English version of the display of Chinese, anyway, is not the result of demand, and finally draw on the practice of colleagues to solve.

Needless to say, first, you have to prepare a set of pictures:

Probably not, these three pictures 2xhe3x two sets of pictures, a total of six, drag these pictures to assets.xcassets, such as

So you do not have the Chinese and English font name of the picture is called launch. Note that you need to set this noun when setting launch S C reend later.

Set up your new Launchscreen file in Project-target-general-app icons and launch images:

Create a new name for launch screen storyboard, drag Uiimageview into the story version, set the constraints, how much?

And then what? The picture with no English font and no Chinese font is set to ImageView's name launch:

Finally, inside the App de le GA te:

Func application (application:uiapplication, didfinishlaunchingwithoptions launchoptions: [Nsobject:anyobject]?)- > Bool {

Self.window = Uiwindow.init (frame:uiscreen. Mainscreen (). Bounds)

Let login = Uinavigationcontroller.init (Rootviewcontroller:loginviewcontroller ())

Self.window?. Rootviewcontroller = Login

Self.window?. Makekeyandvisible ()

Showlaunchscreen ()

}

Private Func Showlaunchscreen () {

Let launchscreenimg = Uiimageview.init (frame:cgrectmake (0, 0, kscreenwidth, kscreenheight))

Launchscreenimg.image = UIImage (named:nslocalizedstring ("Login_launchscreen", Comment: ""))

window!. Addsubview (LAUNCHSCREENIMG)

Uiview.animatewithduration (0.35, Delay:1, options:. Curveeasein, animations: {

Launchscreenimg.alpha = 0

}) {(finish) in

Launchscreenimg.removefromsuperview ()

}

}

Pay attention to internationalization documents:

"Login_launchscreen" = "chinese.jpg";

"Login_launchscreen" = "english.jpg";

That's it.

swift--Start Page internationalization: Load the start page picture dynamically, load the text when you start

Related Article

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.