• <tfoot id='4rZjR'></tfoot>
    • <bdo id='4rZjR'></bdo><ul id='4rZjR'></ul>

        <i id='4rZjR'><tr id='4rZjR'><dt id='4rZjR'><q id='4rZjR'><span id='4rZjR'><b id='4rZjR'><form id='4rZjR'><ins id='4rZjR'></ins><ul id='4rZjR'></ul><sub id='4rZjR'></sub></form><legend id='4rZjR'></legend><bdo id='4rZjR'><pre id='4rZjR'><center id='4rZjR'></center></pre></bdo></b><th id='4rZjR'></th></span></q></dt></tr></i><div id='4rZjR'><tfoot id='4rZjR'></tfoot><dl id='4rZjR'><fieldset id='4rZjR'></fieldset></dl></div>

      1. <legend id='4rZjR'><style id='4rZjR'><dir id='4rZjR'><q id='4rZjR'></q></dir></style></legend>

        <small id='4rZjR'></small><noframes id='4rZjR'>

      2. 将我的自定义图标添加到 ionic 2 actionSheet 的按钮

        时间:2023-09-07

          • <bdo id='ZvmFJ'></bdo><ul id='ZvmFJ'></ul>
            • <small id='ZvmFJ'></small><noframes id='ZvmFJ'>

                  <tbody id='ZvmFJ'></tbody>

                  <tfoot id='ZvmFJ'></tfoot>

                1. <legend id='ZvmFJ'><style id='ZvmFJ'><dir id='ZvmFJ'><q id='ZvmFJ'></q></dir></style></legend>

                2. <i id='ZvmFJ'><tr id='ZvmFJ'><dt id='ZvmFJ'><q id='ZvmFJ'><span id='ZvmFJ'><b id='ZvmFJ'><form id='ZvmFJ'><ins id='ZvmFJ'></ins><ul id='ZvmFJ'></ul><sub id='ZvmFJ'></sub></form><legend id='ZvmFJ'></legend><bdo id='ZvmFJ'><pre id='ZvmFJ'><center id='ZvmFJ'></center></pre></bdo></b><th id='ZvmFJ'></th></span></q></dt></tr></i><div id='ZvmFJ'><tfoot id='ZvmFJ'></tfoot><dl id='ZvmFJ'><fieldset id='ZvmFJ'></fieldset></dl></div>
                  本文介绍了将我的自定义图标添加到 ionic 2 actionSheet 的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我找不到将自定义图标添加到 ionic 2/3 actionSheet 的方法.

                  I couldn't find a way to add my custom icon to ionic 2/3 actionSheet.

                  presentActionSheet() {
                     let actionSheet = this.actionSheetCtrl.create({
                       title: 'Mode',     
                       buttons: [
                         {
                           text: 'Add to Y' ,
                           role: 'destructive',
                           icon:"my_icon",
                           cssClass:"yoy",
                           handler: () => {
                             console.log('Destructive clicked');
                           }
                         },   
                         {
                           text: 'Cancel',
                           role: 'cancel',
                           handler: () => {
                             console.log('Cancel clicked');
                           }
                         }
                       ],
                  
                     });
                  
                     actionSheet.present();
                   }
                  

                  如何将我自己的自定义图标添加到操作表按钮?

                  How can I add my own custom icons to the actionsheet buttons?

                  推荐答案

                  ionic doc 似乎没有提出任何本地方法来做到这一点.但是,有一种方法可以使用自定义类来实现.

                  The ionic doc doesn't seem to propose any native way to do this. However, there is a way to achieve it using a custom class.

                     let actionSheet = this.actionSheetCtrl.create({
                       title: 'Mode',     
                       buttons: [
                         {
                           text: 'Add to Y',
                           // vvvvv set a custom class that will be used to display the icon
                           cssClass: "class_used_to_set_icon",
                           handler: () => {
                             console.log('Add to Y clicked');
                           }
                         }
                       ],
                  
                     });
                  
                     actionSheet.present();
                  

                  然后在您的 src/app/app.scss 中定义以下类:

                  Then in your src/app/app.scss define the following class:

                  .class_used_to_set_icon {
                    // I'd suggest to have the icon in src/assets (eg ../assets/icon/favicon.ico)
                    background-image: url("path/to/your/icon") !important;
                    // to properly position the icon:
                    background-repeat: no-repeat !important;
                    background-position: 10px 10px !important;
                    // to indent the text to the right of the icon:
                    padding-left: 70px !important;
                  }
                  


                  编辑
                  另一种使用来自 icomoon 等字体的自定义图标的方法:


                  EDIT
                  Another way using custom icons from a font like icomoon:

                     let actionSheet = this.actionSheetCtrl.create({
                       title: 'Mode',     
                       buttons: [
                         {
                           text: 'Add to Y',
                           // vvvvv set the custom icon class and a custom class to then improve display
                           cssClass: "icon-drink actionSheet_withIcomoon",
                           handler: () => {
                             console.log('Add to Y clicked');
                           }
                         }
                       ],
                  
                     });
                  
                     actionSheet.present();
                  

                  然后在您的 src/app/app.scss 中定义以下类:

                  Then in your src/app/app.scss define the following class:

                  // display the icon at the right size
                  .actionSheet_withIcomoon { font-size: 2.4rem !important; }
                  // correct the font dimensions and positioning of the text
                  .actionSheet_withIcomoon .button-inner {
                    font-family: "Roboto", "Helvetica Neue", sans-serif;
                    font-weight: bold;
                    padding-left: 52px;
                    margin-top: -20px;
                    font-size: 1.6rem !important;
                  }
                  

                  这篇关于将我的自定义图标添加到 ionic 2 actionSheet 的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:以角度每 x 秒发出一次 http 请求 下一篇:当用户完成输入而不是按键时运行javascript函数

                  相关文章

                  最新文章

                  <small id='MiEli'></small><noframes id='MiEli'>

                3. <legend id='MiEli'><style id='MiEli'><dir id='MiEli'><q id='MiEli'></q></dir></style></legend>

                      <i id='MiEli'><tr id='MiEli'><dt id='MiEli'><q id='MiEli'><span id='MiEli'><b id='MiEli'><form id='MiEli'><ins id='MiEli'></ins><ul id='MiEli'></ul><sub id='MiEli'></sub></form><legend id='MiEli'></legend><bdo id='MiEli'><pre id='MiEli'><center id='MiEli'></center></pre></bdo></b><th id='MiEli'></th></span></q></dt></tr></i><div id='MiEli'><tfoot id='MiEli'></tfoot><dl id='MiEli'><fieldset id='MiEli'></fieldset></dl></div>
                      • <bdo id='MiEli'></bdo><ul id='MiEli'></ul>
                      <tfoot id='MiEli'></tfoot>