是这种效果吗?import { CustomTabBar } from './CustomTabBar'; @Entry @Component struct Index { tabController: TabsController = new TabsController() @State currentIndex: number = 0; @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack() @Builder build() { Navigation(this.pageInfos) { Stack() { Flex({ direction: FlexDirection.Column }) { Tabs({ barPosition: BarPosition.End, //底部导航 index: this.currentIndex, controller: this.tabController }) { TabContent() { Row() { Text('首页的内容').fontSize(30).width('100%').height('100%').backgroundColor(Color.Red) .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP]) }.height('100%') } TabContent() { Text('消息') } TabContent() { Text('服务') } TabContent() { Text('小慧') } TabContent() { Text('我的') } } .clip(false) .animationDuration(0) //去掉切换页面的动画 .scrollable(false) //去掉左右滑动的效果 .barHeight(0) .layoutWeight(1) .scrollable(false) .onChange((index: number) => { this.currentIndex = index }) CustomTabBar({ currentIndex: $currentIndex }) } }.width('100%') .height('100%') } .hideTitleBar(true) .mode(NavigationMode.Stack) } }// CustomTabBar.ets import curves from '@ohos.curves'; class SetSlt{ isAnimation:boolean = true set():void{ this.isAnimation = !this.isAnimation; } } @Preview @Component export struct CustomTabBar { @Link currentIndex: number; @State subscriptStr: string = '' // 第一步:声明相关状态变量 @State SetAnimation: SetSlt = new SetSlt(); build() { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceAround }) { ForEach(TabsInfos, (item: tabInfo, index: number) => { Column() { if (index === 2) { Column({ space: 10 }){ Column(){ Image(item.icon) .size({width: 60 , height: 45 }) .interpolation(ImageInterpolation.High) } .padding(2) .margin({top:-30}) .backgroundColor(Color.Transparent) // 第二步:将状态变量设置到相关可动画属性接口 .scale({ x: this.SetAnimation.isAnimation ? 1 : 2, y: this.SetAnimation.isAnimation ? 1 : 2 }) .animation({ curve: curves.springMotion(0.4, 0.8) }) .onClick(() => { this.SetAnimation.set() this.currentIndex = index }) } } else { Column({ space: 5 }){ Image(this.currentIndex === index ? item.iconSel : item.icon) .size({ width: 30, height: 30 }) } } } .onClick(() => { this.currentIndex = index }) }, (item: tabInfo) => JSON.stringify(item)) } .padding({ top: 5, bottom: Number(AppStorage.get('bottomRectHeight')) }) .backgroundColor(Color.White) .shadow({radius:10,color:"#fff8f5f5", offsetY: -13}) } } // constantData.ets export interface tabInfo { icon: Resource iconSel: Resource title: string } export const TabsInfos: tabInfo[] = [ { icon: $r('app.media.icon'), iconSel: $r('app.media.background'), title: '首页' }, { icon: $r('app.media.icon'), iconSel: $r('app.media.background'), title: '消息' }, { icon: $r('app.media.background'), iconSel: $r('app.media.icon'), title: '服务' }, { icon: $r('app.media.icon'), iconSel: $r('app.media.background'), title: '小慧' }, { icon: $r('app.media.icon'), iconSel: $r('app.media.background'), title: '我的' }, ]
是这种效果吗?