KScrollViewFramework 滾動視圖?
特點:
Swift語言封裝,使用鏈式編程思想進行創建,使代碼更加優雅!
你可以根據需要對其樣式進行自定義設置。
OC和Swift都可使用,OC使用時候需要進行橋接。
cocoapod使用:
platform :ios, '13.0'
target 'xxxx-DemoName' do
? use_frameworks!
? pod 'KScrollViewFramework'
end
公共接口API:
1??實例化接口
K_ShareInitView(_ blcokView:(KScrollview) -> Void) -> KScrollview? ? // 返回值可有可無,鏈式編程的一種特性
2??獲取數據接口
getData(_ dataArray: [UIImage]) -> KScrollview? ? ? ? ? ? ? ? ? ? ? ? // 返回值可有可無,鏈式編程的一種特性
3??代理方法接口
didSelectItem(index:Int) -> Void? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 選中時響應對應item
配置屬性接口:
K_MakeDelegate ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 代理
K_MakeFrame ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 設置坐標位置
K_MakeSuperView ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 添加到父視圖上
K_MakeItem_heiht ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? // 圖片高度
K_MakeMarginDistanDce_LeftAndRight ? ? // 邊緣左右距離
K_MakeMarginDistanDce_TopAndBottom ? // 邊緣上下距離
K_MakeMargin_BGColor ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// 邊緣背景顏色
K_MakeBorder_width? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ? // 邊框寬度
K_MakeBorder_color? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ?// 邊框顏色
K_MakePage_Tintcolor? ? ? ? ? ? ? ?? ? ? ? ? ? ? ?? ? // 標點背景顏色
K_MakePage_CurrentTintColor? ? ? ? ? ? ? ??? ? ?// 當前標點顯示顏色
K_MakePage_BottomMarginDistanDce ? ? ? ?// 標點視圖距離下邊沿的距離
K_MakeSAnimation? ? ? ? ? ? ? ? ?? ? ? ? ? ? ?? ? ? ? ? ?// 是否有動畫
K_MakeAnimationEstimate? ? ? ? ? ? ? ? ? ? ? ? ?? ? // 動畫幅度系數 0~1之間
K_MakeIsAutoScroll? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? ?? ? // 是否自動滾動
K_MakeTimeInterval? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ? ? // 滾動間隔時間(秒:s)
swift語言調用【現實例化并配置屬性,再進行綁定數據】
// 導入頭文件
import KScrollViewFramework? ? ? ? ? ? ?
// 實例化對象(及其設置屬性)
let kScrollview = KScrollview.K_ShareInitView { (make) in
? ? ? ? ? ? ? ? ? ? ? make.K_MakeFrame(CGRect(x: 0, y: kScaleWidth(100), width: KScreen_Width, height: kScaleWidth(220)))
? ? ? ? ? ? ? ? ? ? ? .K_MakeSuperView(self.view)
? ? ? ? ? ? ? ? ? ? ? .K_MakeItem_heiht(160)? ? ? ? ? ? ? ? ? ? ? // 視圖內容(圖片)高度
? ? ? ? ? ? ? ? ? ? ? .K_MakeMarginDistanDce_LeftAndRight(10)? ? // 左右邊距
? ? ? ? ? ? ? ? ? ? ? .K_MakeMarginDistanDce_TopAndBottom(5)? ? ? // 上下邊距
? ? ? ? ? ? ? ? ? ? ? .K_MakeBorder_color(.black)? ? ? ? ? ? ? ? // 邊框顏色
? ? ? ? ? ? ? ? ? ? ? .K_MakeMargin_BGColor(.yellow)? ? ? ? ? ? ? // 邊沿背景顏色
? ? ? ? ? ? ? ? ? ? ? .K_MakeIsAnimation(true)? ? ? ? ? ? ? ? ? ? // 滾動視圖動畫:fales無動畫,true有動畫
? ? ? ? ? ? ? ? ? ? ? .K_MakeDelegate(self)? ? ? ? ? ? ? ? ? ? ? // 代理方法
? ? ? ? ? ? ? ? ? ? ? .K_MakeAnimationEstimate(0.3)? ? ? ? ? ? ? // 動畫幅度系數0~1
? ? ? ? ? ? ? }
// 獲取綁定數據源
kScrollview.getData(imgArray)
OC語言調用【現實例化并配置屬性,再進行綁定數據】
// 導入頭文件
#import <KScrollViewFramework-Swift.h>
// 實例化對象(及其設置屬性)
KScrollview *kScrollview = [KScrollview K_ShareInitView:^(KScrollview * _Nonnull make) {
? ? [make K_MakeFrame:CGRectMake(0, 180, self.view.frame.size.width, 160)];
? ? [make K_MakeSuperView:self.view];
? ? [make K_MakeIsAnimation:false];
? ? [make K_MakeItem_heiht:150];
? ? [make K_MakeMarginDistanDce_TopAndBottom:5];
? ? [make K_MakeMargin_BGColor:[UIColor whiteColor]];
? ? [make K_MakeMarginDistanDce_LeftAndRight:10];
}];
// 獲取綁定數據源
[kScrollview getData:dataArray];
OC使用Swift第三方庫的橋接的三個步驟:
1、創建.h文件,名為“工程名-Bridging-Header.h”;
2、在Build Setting配置兩個值:
? ? ? 1??設置Defines Module 為Yes;
? ? ? 2??設置Product Module Name 為當前工程名 (有時系統會自動為我們設置好);
3、導入一個頭文件“工程名-Swift.h”就可以使用了,如:#import <KProgressFramework-Swift.h>。