The implementation of the switch skin

Source: Internet
Author: User

For detailed code, go to: Https://git.oschina.net/null_248_6948/skinChange

1. Interface Construction

#01. add three buttons to StackView, location set to - +

#02. Supporting line

#03. set tag

#04. Animation Execution

Skinviewtopcons.constant = Skinviewtopcons.constant = = 0? -44:0

Self.view.layoutIfNeeded ()

2. Basic Implementation :

#01. set the skin according to the pictures provided

Bgimageview.image = UIImage (named: "Skin/\ (skinname)/back.png")

Iconbutton.setimage (UIImage (named: "Skin/\ (skinname)/icon.png"), for:. Normal)

#02. Save the current skin in a sandbox

UserDefaults.standard.set (Skinname, Forkey:kskinkey)

Force sync Current skin to sandbox

#03. Set Default skin ( default if skin is stored in sandbox )

UserDefaults.standard.object (Forkey:kskinkey) as? String?? "Chunjie"

3. Multi-Controller skin replacement :

#01. new otherviewcontroller.swift

used to display the skin of a jump to another interface , preserving the skin before switching good

#02. new hjjskintools.swift

1. Set boot display skin ( override method )

2. This is used for processing : returns the corresponding picture after passing in the picture name

4. Toggle Background Color :

#01. write a class method in the tool class to determine the processing callback color

#02. The controller receives and displays the color on the LabelView

Some of the bugs that may occur:

The implementation of the switch skin

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.