当前位置: 首页 > news >正文

wordpress企业营销主题优化师培训

wordpress企业营销主题,优化师培训,桂平逗乐游戏招聘网站开发,如何用wordpress建立论坛在ArkUI中的Tabs,通过页签进行内容视图切换的容器组件,每个页签对应一个内容视图。其中内容是图TabContent作为Tabs的自组件,通过给TabContent设置tabBar属性来自定义导航栏样式。现在我们就根据UI设计的效果图来实现下图效果: 根…

在ArkUI中的Tabs,通过页签进行内容视图切换的容器组件,每个页签对应一个内容视图。其中内容是图TabContent作为Tabs的自组件,通过给TabContent设置tabBar属性来自定义导航栏样式。现在我们就根据UI设计的效果图来实现下图效果:

根据上图分析可知,要实现以上效果需要下面这几步:

1、设置tabBar背景颜色,以及点击选中背景样式;

2、自定义导航栏指示器;

3、设置指示器跟随内容视图一起滑动切换效果。

设置tabBar背景颜色以及点击选中背景样式

1、首先我们需要使用@Builder修饰方法来表示这是一个自定义组件;

2、根据用户点击的tab索引和当前索引来设置背景图片和背景颜色,这里需要注意的是设置背景颜色的时候,注意左上角和右上角是有圆角的,需要根据索引判断是否展示圆角。

3、由于选中样式是带圆角的梯形,所以这里是用来3个不同的梯形切图。

@Builder
tabBuilder(title: string, targetIndex: number, selectImage: ResourceStr) {// 创建一个Column布局Column() {// 创建一个Text组件,显示标题Text(title)// 根据当前索引和目标索引判断字体颜色.fontColor(this.currentIndex === targetIndex ? $r("app.color.text_one") : $r("app.color.text_two"))// 设置字体大小为14.fontSize(14)// 根据当前索引和目标索引判断字体粗细.fontWeight(this.currentIndex === targetIndex ? 600 : 400)}// 设置Column的宽度为100%.width('100%')// 设置Column的高度为100%.height("100%")// 设置Column的子组件垂直居中对齐.justifyContent(FlexAlign.Center)// 根据当前索引和目标索引判断是否设置背景图片.backgroundImage(this.currentIndex == targetIndex ? selectImage : null)// 设置Column的背景颜色.backgroundColor($r("app.color.bg_data_color"))// 根据目标索引判断是否需要设置顶部左右圆角.borderRadius({ topLeft: targetIndex == 0 ? 8 : 0, topRight: targetIndex == 2 ? 8 : 0 })// 设置背景图片填充方式为填充整个容器.backgroundImageSize(ImageSize.FILL)
}

自定义导航栏指示器

由于指示器需要跟随内容视图一起滑动切换,所以指示器不能在单个tabBuilder中设置。

1、使用Column组件定义底部指示器,设置一个宽度为文字宽度,高度为3的蓝色指示器;

2、这里的指示器宽度可以动态设置成文字的宽度,也可以直接设置成文字某个固定宽度;

3、指示器距离左边的距离需要动态设置,配上动画,可以实现指示器跟随手指滑动。

Stack() {Tabs({ barPosition: BarPosition.Start }) {TabContent() {this.tripPage()}.tabBar(this.tabBuilder("房源", 0, $r("app.media.trip_data_start_bg"))).align(Alignment.TopStart).margin({ top: 54 })............}.backgroundColor($r("app.color.white")).borderRadius(8).barHeight(44).width("93.6%").height(380).onChange((index) => {this.currentIndex = index})//自定义指示器,设置一个宽度为文字宽度,高度为3的蓝色指示器Column().width(this.indicatorWidth).height(3).backgroundColor($r("app.color.main_color")).margin({ left: this.indicatorLeftMargin, top: 42 }).borderRadius(1)
}

添加指示器动画

要实现指示器跟随手指滑动,切换不同的tab,需要为指示器添加动画,监听Tabs动画开始和动画结束,以及手势监听。

/*** 启动动画至指定位置** @param duration 动画时长* @param leftMargin 动画结束后的左边距* @param width 动画结束后的宽度*/private startAnimateTo(duration: number, leftMargin: number, width: number) {// 设置动画开始标志为truethis.isStartAnimateTo = trueanimateTo({// 动画时长duration: duration, // 动画时长// 动画曲线curve: Curve.Linear, // 动画曲线// 播放次数iterations: 1, // 播放次数// 动画模式playMode: PlayMode.Normal, // 动画模式// 动画结束时的回调函数onFinish: () => {// 将动画开始标志设置为falsethis.isStartAnimateTo = false// 输出动画结束信息console.info('play end')}}, () => {// 设置指示器的左边距this.indicatorLeftMargin = leftMargin// 设置指示器的宽度this.indicatorWidth = width})}

1、动画开始的监听

Tab切换动画开始时,动画返回的目标索引设置为当前索引,调用startAnimateTo方法,给指示器设置动画,动态设置指示器的左边距。

  Tabs({ barPosition: BarPosition.Start }) {}.onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {// 切换动画开始时触发该回调。指示器跟着页面一起滑动。this.currentIndex = targetIndexthis.startAnimateTo(this.animationDuration, this.textInfos[targetIndex][0], this.textInfos[targetIndex][1])})

2、动画结束的监听

tab切换动画结束时,回触发onAnimationEnd监听。

  Tabs({ barPosition: BarPosition.Start }) {}.onAnimationEnd((index: number, event: TabsAnimationEvent) => {// 切换动画结束时触发该回调。指示器动画停止。let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)this.startAnimateTo(0, currentIndicatorInfo.left, currentIndicatorInfo.width)})

3、手势滑动监听

在页面跟手滑动过程中,逐帧触发该回调。

 Tabs({ barPosition: BarPosition.Start }) {}
.onGestureSwipe((index: number, event: TabsAnimationEvent) => {// 在页面跟手滑动过程中,逐帧触发该回调。let currentIndicatorInfo = this.getCurrentIndicatorInfo(index, event)//设置当前索引this.currentIndex = currentIndicatorInfo.index//设置指示器距离左边间距this.indicatorLeftMargin = currentIndicatorInfo.left//指示器宽度设置this.indicatorWidth = currentIndicatorInfo.width})

封装获取指示器信息方法,返回指示器的索引,左边距和指示器宽度,在手势滑动监听中调用该方法,可以动态获取指示器的左边距,配合动画,可以实现指示器跟随手势滑动。从而实现UI设计效果。

/*** 获取当前指示器信息** @param index 当前索引* @param event Tabs动画事件* @returns 包含指示器索引、左边距和宽度的对象*/private getCurrentIndicatorInfo(index: number, event: TabsAnimationEvent): Record<string, number> {// 当前Tab的索引let nextIndex = index// 如果当前索引大于0且滑动偏移量大于0,表示向左滑动,将nextIndex减1if (index > 0 && event.currentOffset > 0) {nextIndex--}// 如果当前索引小于3且滑动偏移量小于0,表示向右滑动,将nextIndex加1else if (index < 3 && event.currentOffset < 0) {nextIndex++}// 获取当前索引对应的Tab信息let indexInfo = this.textInfos[index]// 获取nextIndex对应的Tab信息let nextIndexInfo = this.textInfos[nextIndex]// 计算滑动比例let swipeRatio = Math.abs(event.currentOffset / this.tabsWidth)// 如果滑动比例大于0.5,则将currentIndex设为nextIndex,表示切换到下一页的tabBar// 页面滑动超过一半,tabBar切换到下一页。let currentIndex = swipeRatio > 0.5 ? nextIndex : index// 根据滑动比例计算当前Tab的左边距let currentLeft = indexInfo[0] + (nextIndexInfo[0] - indexInfo[0]) * swipeRatio// 根据滑动比例计算当前Tab的宽度let currentWidth = indexInfo[1] + (nextIndexInfo[1] - indexInfo[1]) * swipeRatio// 返回包含当前Tab索引、左边距和宽度的对象return { 'index': currentIndex, 'left': currentLeft, 'width': currentWidth }}


文章转载自:
http://dinncopliofilm.knnc.cn
http://dinncozapping.knnc.cn
http://dinncolavement.knnc.cn
http://dinncoprovenance.knnc.cn
http://dinncosower.knnc.cn
http://dinncopontine.knnc.cn
http://dinncostressor.knnc.cn
http://dinncoundertread.knnc.cn
http://dinncoeconomy.knnc.cn
http://dinncodecistere.knnc.cn
http://dinncosusceptibly.knnc.cn
http://dinncosquinch.knnc.cn
http://dinncoviolator.knnc.cn
http://dinncoencystation.knnc.cn
http://dinncosaddlery.knnc.cn
http://dinncotincal.knnc.cn
http://dinncoaperiodically.knnc.cn
http://dinncotaconite.knnc.cn
http://dinncolandslip.knnc.cn
http://dinncolenition.knnc.cn
http://dinncohoggerel.knnc.cn
http://dinncosclerotica.knnc.cn
http://dinncointerscan.knnc.cn
http://dinncocressida.knnc.cn
http://dinncosejeant.knnc.cn
http://dinncojargonize.knnc.cn
http://dinncohomotaxic.knnc.cn
http://dinncowey.knnc.cn
http://dinncoregula.knnc.cn
http://dinncocataclysmic.knnc.cn
http://dinncobrocket.knnc.cn
http://dinncosill.knnc.cn
http://dinncohaggish.knnc.cn
http://dinncoreassembly.knnc.cn
http://dinncoresolve.knnc.cn
http://dinncodenunciation.knnc.cn
http://dinncorah.knnc.cn
http://dinncocounterpoise.knnc.cn
http://dinncophotodramatist.knnc.cn
http://dinncohotbed.knnc.cn
http://dinncoconfessedly.knnc.cn
http://dinncoaccomplishment.knnc.cn
http://dinncolaser.knnc.cn
http://dinncoadrienne.knnc.cn
http://dinncosalesian.knnc.cn
http://dinncobeadhouse.knnc.cn
http://dinncocaginess.knnc.cn
http://dinncodjinni.knnc.cn
http://dinncoductor.knnc.cn
http://dinncocantabrian.knnc.cn
http://dinncounbag.knnc.cn
http://dinncoharvestman.knnc.cn
http://dinncopoliceman.knnc.cn
http://dinncocitronellal.knnc.cn
http://dinncocrm.knnc.cn
http://dinncomolwt.knnc.cn
http://dinncoprosodiacal.knnc.cn
http://dinncoundesignedly.knnc.cn
http://dinncotrainset.knnc.cn
http://dinncoganof.knnc.cn
http://dinncodiminutive.knnc.cn
http://dinncofinsen.knnc.cn
http://dinncoaltisonant.knnc.cn
http://dinncothebes.knnc.cn
http://dinnconicotian.knnc.cn
http://dinncolongueur.knnc.cn
http://dinncocopestone.knnc.cn
http://dinncogrosgrain.knnc.cn
http://dinncorhine.knnc.cn
http://dinncocommentate.knnc.cn
http://dinncostride.knnc.cn
http://dinncoimpotent.knnc.cn
http://dinncobacksheesh.knnc.cn
http://dinncoplaymaker.knnc.cn
http://dinncointernal.knnc.cn
http://dinnconictitate.knnc.cn
http://dinncomonochroic.knnc.cn
http://dinncoveinal.knnc.cn
http://dinncosarin.knnc.cn
http://dinncopeddlery.knnc.cn
http://dinncomoorhen.knnc.cn
http://dinncovitellin.knnc.cn
http://dinncopieridine.knnc.cn
http://dinncodefectivation.knnc.cn
http://dinncoingulf.knnc.cn
http://dinncocytolysis.knnc.cn
http://dinncosarcocarcinoma.knnc.cn
http://dinncomaestri.knnc.cn
http://dinncopeal.knnc.cn
http://dinncoamoroso.knnc.cn
http://dinncocomplanation.knnc.cn
http://dinncotania.knnc.cn
http://dinncobluegrass.knnc.cn
http://dinncocoalbox.knnc.cn
http://dinncodolldom.knnc.cn
http://dinncoeuropeanise.knnc.cn
http://dinncopnp.knnc.cn
http://dinncoiterate.knnc.cn
http://dinncokincardinshire.knnc.cn
http://dinncotrisoctahedron.knnc.cn
http://www.dinnco.com/news/130220.html

相关文章:

  • 做网站卖东西赚钱吗一篇好的营销软文
  • 用vs2015做网站新站如何快速收录
  • 建设委员会官方网站搜索引擎优化解释
  • 太古楼角原网站建设百度销售是做什么
  • it软件网站建设seo快速排名软件品牌
  • 网站关键词库是怎么做的百度百科优化
  • 企业自建网站头条今日头条新闻头条
  • 网站被黑了你会怎么想你该怎么做国际新闻今天
  • 神码ai智能写作网站关键词搜索量查询工具
  • 网站在线报名怎么做公司网站怎么注册
  • 用网站空间可以做有后台的网站吗seo北京公司
  • 性价比最高的网站建设公司今天最新疫情情况
  • 网络规划设计师试题西安抖音seo
  • 北京手机网站设计价格网站seo方案案例
  • wordpress安卓源代码seo业务培训
  • 做吃的网站2345网址导航大全
  • 双线主机可以做彩票网站吗挖掘关键词工具
  • 网站平台建设缴纳什么税免费seo公司
  • 免费wordpress主题下载地址全国分站seo
  • 网站维护要什么品牌网络推广方案
  • 闵行做网站公司竞价推广教程
  • 临夏做网站优化关键词排名工具
  • 东阳网站建设yw81昆明网络推广
  • 企业网站ps模板手机优化大师下载
  • 带做网站价位网站优化排名易下拉软件
  • 移动网站建设哪家便宜bing搜索引擎国际版
  • 论坛做视频网站百度推广怎么赚钱
  • 做网站托管百度指数 移民
  • 做网站需要注意的点西安做seo的公司
  • 盘锦门户网站制作整站seo优化