封装常用控制器

embedded/2025/2/6 11:40:56/

封装常用控制器

在这里插入图片描述

//
//  BaseLogicController.swift
//  项目中通用的逻辑控制器import UIKit
import TangramKitclass BaseLogicController: BaseCommonController {/// 根容器var rootContainer:TGBaseLayout!/// 头部容器var superHeaderContainer:TGBaseLayout!var superHeaderContentContainer:TGBaseLayout!/// 底部容器var superFooterContainer:TGBaseLayout!var superFooterContentContainer:TGBaseLayout!/// 容器var container:TGBaseLayout!/// 初始化RelativeLayout容器,四边都在安全区内func initRelativeLayoutSafeArea() {initLinearLayout()//headerinitHeaderContainer()container = TGRelativeLayout()container.tg_width.equal(.fill)container.tg_height.equal(.fill)container.backgroundColor = .clearrootContainer.addSubview(container)initFooterContainer()}/// 初始化垂直方向LinearLayout容器,四边都在安全区内func initLinearLayoutSafeArea() {initLinearLayout()//headerinitHeaderContainer()//frameframeContainer=TGRelativeLayout();frameContainer.tg_width.equal(.fill)frameContainer.tg_height.equal(.fill)frameContainer.backgroundColor = .clearrootContainer.addSubview(frameContainer)container = TGLinearLayout(.vert)container.tg_width.equal(.fill)container.tg_height.equal(.fill)container.backgroundColor = .clearframeContainer.addSubview(container)initFooterContainer()}/// 初始化垂直方向LinearLayout容器,只有顶部不在安全区func initLinearLayoutTopNotSafeArea() {rootContainer = TGRelativeLayout()rootContainer.tg_width.equal(.fill)rootContainer.tg_height.equal(.fill)rootContainer.backgroundColor = .clearself.view.addSubview(rootContainer)container=TGLinearLayout(.vert)container.tg_width.equal(.fill)container.tg_height.equal(.fill)container.backgroundColor = .clearcontainer.tg_bottom.equal(TGLayoutPos.tg_safeAreaMargin)rootContainer.addSubview(container)//headerinitHeaderContainer()}/// 头部容器,安全区外,一般用来设置头部到安全区外背景颜色func initHeaderContainer() {superHeaderContainer = TGLinearLayout(.vert)superHeaderContainer.tg_width.equal(.fill)superHeaderContainer.tg_height.equal(.wrap)superHeaderContainer.backgroundColor = .clear//头部内容容器,安全区内superHeaderContentContainer = TGLinearLayout(.vert)superHeaderContentContainer.tg_height.equal(.wrap)superHeaderContentContainer.tg_leading.equal(TGLayoutPos.tg_safeAreaMargin)superHeaderContentContainer.tg_trailing.equal(TGLayoutPos.tg_safeAreaMargin)superHeaderContentContainer.tg_top.equal(TGLayoutPos.tg_safeAreaMargin)superHeaderContentContainer.backgroundColor = .clearsuperHeaderContainer.addSubview(superHeaderContentContainer)rootContainer.addSubview(superHeaderContainer)}func initFooterContainer() {superFooterContainer = TGLinearLayout(.vert)superFooterContainer.tg_width.equal(.fill)superFooterContainer.tg_height.equal(.wrap)superFooterContainer.backgroundColor = .clear//底部内容容器,安全区内superFooterContentContainer = TGLinearLayout(.vert)superFooterContentContainer.tg_height.equal(.wrap)superFooterContentContainer.tg_leading.equal(TGLayoutPos.tg_safeAreaMargin)superFooterContentContainer.tg_trailing.equal(TGLayoutPos.tg_safeAreaMargin)superFooterContentContainer.tg_bottom.equal(TGLayoutPos.tg_safeAreaMargin)superFooterContentContainer.backgroundColor = .clearsuperFooterContainer.addSubview(superFooterContentContainer)rootContainer.addSubview(superFooterContainer)}}

在这里插入图片描述
这样在controller view中,初始化函数,然后把需要的控件插入即可


http://www.ppmy.cn/embedded/160012.html

相关文章

FFmpeg 头文件完美翻译之 libavfilter 模块

前言 众所周知,FFmpeg 的代码开发上手难度较高,源于官方提供的文档很少有包含代码教程相关的。要想熟练掌握 FFmpeg 的代码库开发,需要借助它的头文件,FFmpeg 把很多代码库教程都写在头文件里面。因此,熟读头文件的内…

【Rust自学】18.3. 模式(匹配)的语法

喜欢的话别忘了点赞、收藏加关注哦(加关注即可阅读全文),对接下来的教程有兴趣的可以关注专栏。谢谢喵!(・ω・) 18.3.1. 匹配字面值 模式可以直接匹配字面值。看个例子: let x 1;match x {1…

在Mapbox GL JS中“line-pattern”的使用详解

在Mapbox GL JS中,line-pattern 是一种用于在地图上绘制带有图案的线条的样式属性。通过 line-pattern,你可以使用自定义的图像作为线条的图案,而不是使用纯色或渐变。 1. 基本概念 line-pattern: 该属性允许你指定一个图像作为线条的图案。…

WordPress自定义.js文件排序实现方法

在WordPress中,要将插件引用的.js文件放到所有.js文件之后加载,可以通过以下方法实现: 方法一:调整wp_enqueue_script的加载顺序 在插件的主文件中,使用wp_enqueue_script函数加载.js文件时,将$in_footer…

Spring Boot 2 快速教程:WebFlux 集成 Mongodb(三)

一、前言 上一讲用 Map 数据结构内存式存储了数据。这样数据就不会持久化,本文我们用 MongoDB 来实现 WebFlux 对数据源的操作。 什么是 MongoDB ? 官网:https://www.mongodb.com/ MongoDB 是一个基于分布式文件存储的数据库,由 C 语言编…

《redis4.0 通信模块源码分析(一)》

【redis导读】redis作为一款高性能的内存数据库,面试服务端开发,redis是绕不开的话题,如果想提升自己的网络编程的水平和技巧,redis这款优秀的开源软件是很值得大家去分析和研究的。 笔者从大学毕业一直有分析redis源码的想法&…

vue2+vue3 HMCXY基础入门

vue2vue3 HMCXY基础入门 一、Vue2.x技术精讲1.Vue快速上手(1)Vue概念(2)创建实例(3)插值表达式(4)响应式特性(5)开发者工具 2.Vue指令二、Vue3.x技术精讲 一、…

【JavaEE】Spring(6):Mybatis(下)

一、Mybatis XML配置文件 Mybatis开发有两种方式: 注解XML 之前讲解了注解的方式,接下来学习XML的方式 1.1 配置数据库连接和Mybatis 直接在配置文件中配置即可: spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mybatis_test?cha…