收藏
回答

自定义tabbar中间凸起部分的圆弧怎么做出来?

自定义的tabbar,中间凸起部分的圆弧怎么做出来?如图二是想要实现的效果,图一中红色框的圆弧要怎么实现?

wxml代码
<view class="tab-bar">
    <view class="tab-bar-border"></view>
    <view class="tab-bar-item" wx:for="{{selectList}}" wx:key="index" data-index="{{index}}" data-path="{{item.pagePath}}" data-selected="{{item.selected}}" bindtap="onwidthTap">
        <image class="cover-image" src="{{selected === item.selected ? item.selectedIconPath : item.iconPath}}"></image>
        <view class="cover-view" style="color:{{selected === item.selected ? selectedColor : color}}">{{item.text}}</view>
    </view>
</view>
<view class="indicator">
    <view class="indicator-border"></view>
    <view class="indicator-item">
        <image class="indicator-image" src="/images/jia.png"></image>
    </view>
    <view class="indicator-item-text">发布</view>
</view>

wxss代码

.tab-bar {
    position: fixed;
    bottom0;
    left0;
    right0;
    height120rpx;
    background-color: white;
    display: flex;
    padding-bottomenv(safe-area-inset-bottom);
    box-shadow0 0 5rpx 0 rgba(0000.33);
}
.tab-bar-item {
    flex1;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.cover-image {
    margin-bottom40rpx;
    width44rpx;
    height44rpx;
}
.tab-bar-item .cover-view {
    font-size34rpx;
    position: absolute;
    bottom10rpx;
    color#7A7E83;
}
.indicator {
    height70rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.indicator-border {
    position: absolute;
    left50%;
    top: -50rpx;
    transformtranslate(-50%, -50%);
    border-radius50%;
    width80rpx;
    height80rpx;
    border7px solid #fff;
    box-shadow0 0 5rpx 0 rgba(0000.33);
    z-index: -1;
}
.indicator-item {
    position: absolute;
    left50%;
    top: -50rpx;
    transformtranslate(-50%, -50%);
    background#ff9f7f;
    border-radius50%;
    width80rpx;
    height80rpx;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    border7px solid #fff;
    z-index1;
}
.indicator-image {
    width80rpx;
    height80rpx;
    border-radius50%;
}
.indicator-item-text {
    font-size34rpx;
    z-index1;
    color#7A7E83;
    position: absolute;
    bottom10rpx;
}
回答关注问题邀请回答
收藏

5 个回答

  • 啊哈
    啊哈
    星期五 19:17

    我用js+scss尝试实现了下这个效果,欢迎体验哈

    https://developers.weixin.qq.com/community/develop/article/doc/00024e9becc7b8fdfd73161746b013

    星期五 19:17
    有用
    回复
  • 夜猫的兔子
    夜猫的兔子
    05-27

    你中间突出的tab 怎么实现的?是写一个tabBar 然后需要底部导航的页面引入吗,小程序自定义的底部导航可以实现吗 ?

    05-27
    有用
    回复 3
    • 蓝天☁
      蓝天☁
      05-30
      这怎么说呢,通过定位,样式设定,你打开代码片段就能看到了
      05-30
      回复
    • 夜猫的兔子
      夜猫的兔子
      06-05回复蓝天☁
      可是手机端有样式兼容问题
      06-05
      回复
    • 蓝天☁
      蓝天☁
      06-12回复夜猫的兔子
      那我就不知道了哦
      06-12
      回复
  • L.
    L.
    04-09

    找一个 我这样的背景

    04-09
    有用
    回复 1
    • 蓝天☁
      蓝天☁
      发表于移动端
      04-09
      没办法就只能这样了
      04-09
      回复
  • 一笑皆春
    一笑皆春
    04-09

    这不很简单,中间的那个大的单独加个view设置圆形样式

    第二种方案设计一张图,不过不如自己view画出来

    04-09
    有用
    回复 4
    • 蓝天☁
      蓝天☁
      发表于移动端
      04-09
      中间那个大圆弄出来了,就是两边的小圆弧怎么弄出来
      04-09
      回复
    • 一笑皆春
      一笑皆春
      04-09回复蓝天☁
      我看还有阴影,你还是找设计一张图片吧,然后定位上
      04-09
      回复
    • 一笑皆春
      一笑皆春
      04-09回复蓝天☁
      或者是试试通过层叠z-index控制层级显示
      04-09
      回复
    • 蓝天☁
      蓝天☁
      发表于移动端
      04-09回复一笑皆春
      那个小圆弧弄了个内凹圆弧,就是阴影弄不出来,是不是小程序上实现不了这个内凹圆弧阴影,或者说弄一半圆圈,再弄一个内凹圆弧覆盖多余的阴影线条?
      04-09
      回复
  • 那一抹微笑😊穿透阳光
    那一抹微笑😊穿透阳光
    04-09

    最简单的方法就是,你把图片设计成图二的样子

    04-09
    有用
    回复 2
登录 后发表内容