How to Use sencha touch 2 sass custom icons

Source: Internet
Author: User

The default icons provided by sencha touch are limited, so there are only a few APIs.

However, to facilitate expansion, sencha touch has already prepared several Icon files and sass code for us to facilitate later CSS customization.

The icon file is under \ resources \ themes \ images \ Default \ pictos. If not, you can place your own PNG images.

How can I customize my own icons?

Because we are a Windows system, we must first install the ruby environment, because the sass and compass tools are attached to Ruby.

Download and install Ruby in 1.360

2. Execute gem install haml

3. Execute gem install compass

4. OK. After installation is complete, CSS can be generated.

5. Prepare a directory. For example, if the sencha touch SDK is placed under the directory http: // localhost/senchatouch/, your icon access address should be

Http: // localhost/senchatouch/resources/themes/images/default/pictos/image name .png

After confirming this, copy all the files under senchatouch/resources/to another directory, for example, F: \ test \ senchatouch \ resources \

6. Edit the F: \ test \ senchatouch \ resources \ sass \ sencha-touch.scss file and add the following code

 

@ Import 'sencha-touch/default/all ';
// These are official ones, which can be removed from the list.
@ Include sencha-panel;
@ Include sencha-buttons;
@ Include sencha-sheet;
@ Include sencha-picker;
@ Include sencha-Tabs;
@ Include sencha-toolbar;
@ Include sencha-toolbar-forms;
@ Include sencha-indexbar;
@ Include sencha-list;
@ Include sencha-list-Paging;
@ Include sencha-list-pullrefresh;
@ Include sencha-layout;
@ Include sencha-incluusel;
@ Include sencha-form;
@ Include sencha-msgbox;
@ Include sencha-loading-spinner;
@ Include sencha-draw;
@ Include sencha-charts;

@ Include pictos-iconmask ("power_on"); // This is the name of the image you want to add. The suffix is omitted. Usage: iconcls: 'Power _ on' @ include pictos-iconmask ("shield2"); @ include pictos-iconmask ("settings11"); @ include pictos-iconmask ("settings9 "); @ include pictos-iconmask ("user_list2"); @ include pictos-iconmask ("doc_list"); @ include pictos-iconmask ("doc_drawer "); @ include pictos-iconmask ("data"); @ include pictos-iconmask ("chart2 ");

7. To ensure that the image address is correctly found, edit the F: \ test \ senchatouch \ resources \ sass \ config. RB file.

# Get the directory that this configuration file exists indir = file. dirname (_ file _) # load the sencha-touch framework automatically. load file. join (Dir, 'HTTP: // www.cnblogs.com/senchatouch/resources', 'themes') // here, if you do not modify it, http: // ip/resources/image # compass configurationssass_path = dircss_path = file. join (Dir ,".. "," CSS ") environment =: productionoutput_style =: Compressed

8. OK. All preparations are completed and the generation starts.

9. Run cmd to enter the F: \ test \ directory and run compass compile.

10. succeeded. In the F: \ test \ senchatouch \ resources \ cssdirectory, open the sencha-touch.css file and copy the final icon CSS to your system's CSS file.

.x-tab .x-button-icon.chart2,.x-button .x-button-icon.x-icon-mask.chart2{-webkit-mask-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAFsUlEQVRoBe2Ze6hVRRTGO+UtC+umRRZpDytMSOpGZQ9DDAsyMrOuQZBEGVwKekmU9E+gRIaKEYV/qNiLrqaEvSjJskKwsKLApKI0I7Ks8Gqp+br9Pt1zGdeZffbc0z56Xgs+Z2atNY9v1szac66F7u7uIxpJjmwksuLaJFzvEW9GuBnhOtuBAnweBefUGa80OnNlWAX0MW4ETGgmLYW8nqXhItwnEM196BaB90Ctbsge1j4DnAYOkhBhOXwJFh/kWVsNJeDHQTThPfyK2lFNHAuFwhmsZzfr+jVmXfjrpBZJWoSLHA+XgoUPYO6pYATYRXsp5QKI/0vZa6l6wjC6DXSAvkBH9QKwDqwEvZaqTkpEU+ubCPoBBacFnALuwXYUZa+lqgnDZjg4y7DSc3gsGGb0Uc1qJzwKFqcGmLSiezigz1QdMsIcwVtAJ1gC7spc2QGHqyh0d60oyjcyzmhryGofkqTFwiawkFng9GRBo9CtJdN+mrZA7PItdWxPwj4ZfJg2Rkhf8QizcM0hwvqOaoOFk0E7tmMp0+Q8DEKaKMqjGeOiNIeQvuKEmfRsoKOpBfrSTmOwr3B1SMi3DYSOs3NTqfs9Dvfok1pRwixE418KzgRWRHZMQs7alJQuN0q9nPRG9kUbcwc431eWqleUMBMfD24HNrpak3T3gxPVMDKQ9rVG10X7LbDJ6PXXmvGxUa40Yd3BMWaBfnMojet9RRJxXYH+vp76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ONb601W0ILDhFWIpsC7g11qCFd/9BaQ4Tl1y9BqE9N63L/LFX7bjQcYR1pvXL0F41GkK16/g0F9q8M9Up+fYHvX72SC/JquDvcJBw8B3WkbEa4joIZpNJwEf4Ps34G72x72yUAAAAASUVORK5CYII=')}

11.

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.