ionic3 之Android的actionsheet渲染和ios一致

Android的action-sheet是比较丑,默认几乎不带样式,如果不给图标的话。如图:

首先对比一下ios和android样式的区别,然后在ionic.css文件中,将ios的action-sheet样式拷贝出来,独立为actionsheet.scss,这样就可以覆盖了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* 覆盖action-sheet样式
*
**/
.action-sheet-md {
text-align: center;
}
.action-sheet-md .action-sheet-container {
padding: 0 10px;
background: none;
}
.action-sheet-md .action-sheet-group {
overflow: hidden;
margin-bottom: 8px;
border-radius: 13px;
background: #f9f9f9;
}
.action-sheet-md .action-sheet-group:last-child {
margin-bottom: 10px;
}
.action-sheet-md .action-sheet-title {
text-align: center;
padding: 1.5rem;
border-bottom: 0.55px solid #d6d6da;
border-radius: 0;
font-size: 1.3rem;
font-weight: 400;
color: #8f8f8f;
}
.action-sheet-md .action-sheet-button {
margin: 0;
padding: 18px;
min-height: 5.6rem;
border-bottom: 0.55px solid #d6d6da;
font-size: 2rem;
color: #007aff;
background: transparent;
.button-inner {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row nowrap;
-ms-flex-flow: row nowrap;
flex-flow: row nowrap;
-webkit-flex-shrink: 0;
-ms-flex-negative: 0;
flex-shrink: 0;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
width: 100%;
height: 100%;
}
}
.action-sheet-md .action-sheet-button:last-child {
border-bottom-color: transparent;
}
.action-sheet-md .action-sheet-button.activated {
margin-top: -0.55px;
border-top: 0.55px solid #ebebeb;
border-bottom-color: #ebebeb;
background: #ebebeb;
}
.action-sheet-md .action-sheet-selected {
font-weight: bold;
background: #fff;
}
.action-sheet-md .action-sheet-destructive {
color: #f53d3d;
}
.action-sheet-md .action-sheet-cancel {
font-weight: 600;
background: #fff;
}

最终效果如图:

其实ionic支持指定UI渲染模式,config设置modeios即可

推荐文章