Skip to content

Commit

Permalink
UILabel支持国际化,FlexXmlBaseView支持代码方式创建,更新FrameView组件的例子
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenglibao committed Feb 19, 2019
1 parent 526fabb commit e431cf0
Show file tree
Hide file tree
Showing 23 changed files with 302 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
**FlexLib**的所有版本的变更日志都将会在这里记录.

---
## 2.2.1
1. UILabel的富文本支持国际化
2. FlexXmlBaseView增加代码创建方式

## 2.2.0
1. 增加FlexXmlBaseView,该类用来制作组件,与FlexCustomBaseView类似,不同的是FlexXmlBaseView的派生类只能用在xml中,好处是减少视图层级

Expand Down
10 changes: 10 additions & 0 deletions Example/FlexLib.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
D297583D1FE0D069004314CF /* qrcode.png in Resources */ = {isa = PBXBuildFile; fileRef = D297583C1FE0D069004314CF /* qrcode.png */; };
D297585E1FE22CF2004314CF /* DemoFlexVC.m in Sources */ = {isa = PBXBuildFile; fileRef = D297585D1FE22CF2004314CF /* DemoFlexVC.m */; };
D29758601FE23DCD004314CF /* justifyContent.xml in Resources */ = {isa = PBXBuildFile; fileRef = D297585F1FE23DCC004314CF /* justifyContent.xml */; };
D29D0D57221BE9B400DE5543 /* TestFrameView.m in Sources */ = {isa = PBXBuildFile; fileRef = D29D0D56221BE9B400DE5543 /* TestFrameView.m */; };
D29D0D59221BEA2500DE5543 /* TestFrameView.xml in Resources */ = {isa = PBXBuildFile; fileRef = D29D0D58221BEA2500DE5543 /* TestFrameView.xml */; };
D2CF9CC11FD7EB0900554A0C /* return@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D2CF9CBA1FD7EB0900554A0C /* return@2x.png */; };
D2CF9CC21FD7EB0900554A0C /* addnewtype@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D2CF9CBB1FD7EB0900554A0C /* addnewtype@2x.png */; };
D2CF9CC31FD7EB0900554A0C /* TestTableCell.xml in Resources */ = {isa = PBXBuildFile; fileRef = D2CF9CBC1FD7EB0900554A0C /* TestTableCell.xml */; };
Expand Down Expand Up @@ -293,6 +295,9 @@
D297585C1FE22CF2004314CF /* DemoFlexVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DemoFlexVC.h; sourceTree = "<group>"; };
D297585D1FE22CF2004314CF /* DemoFlexVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DemoFlexVC.m; sourceTree = "<group>"; };
D297585F1FE23DCC004314CF /* justifyContent.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = justifyContent.xml; path = res/justifyContent.xml; sourceTree = "<group>"; };
D29D0D55221BE9B400DE5543 /* TestFrameView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TestFrameView.h; sourceTree = "<group>"; };
D29D0D56221BE9B400DE5543 /* TestFrameView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TestFrameView.m; sourceTree = "<group>"; };
D29D0D58221BEA2500DE5543 /* TestFrameView.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = TestFrameView.xml; path = res/TestFrameView.xml; sourceTree = "<group>"; };
D2CF9CBA1FD7EB0900554A0C /* return@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "return@2x.png"; path = "res/return@2x.png"; sourceTree = "<group>"; };
D2CF9CBB1FD7EB0900554A0C /* addnewtype@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "addnewtype@2x.png"; path = "res/addnewtype@2x.png"; sourceTree = "<group>"; };
D2CF9CBC1FD7EB0900554A0C /* TestTableCell.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = TestTableCell.xml; path = res/TestTableCell.xml; sourceTree = "<group>"; };
Expand Down Expand Up @@ -424,6 +429,8 @@
D272A8CE1FDA63000075DB1D /* TestModalVC.m */,
D2208DD02205938F00B6819E /* TestXmlView.h */,
D2208DD12205938F00B6819E /* TestXmlView.m */,
D29D0D55221BE9B400DE5543 /* TestFrameView.h */,
D29D0D56221BE9B400DE5543 /* TestFrameView.m */,
D2CF9CC91FD7EB1900554A0C /* TestVC.h */,
D2CF9CCA1FD7EB1900554A0C /* TestVC.m */,
D28F172A200854E500F5AEB2 /* ControlsVC.h */,
Expand Down Expand Up @@ -608,6 +615,7 @@
D2CF9CB91FD7EAFA00554A0C /* res */ = {
isa = PBXGroup;
children = (
D29D0D58221BEA2500DE5543 /* TestFrameView.xml */,
D2208DCE2205937300B6819E /* TestXmlView.xml */,
D2EDA728214B8D7400B6A26D /* TestCollectionCell.xml */,
D2EDA723214B8B5C00B6A26D /* TestCollectionViewVC.xml */,
Expand Down Expand Up @@ -798,6 +806,7 @@
D297583D1FE0D069004314CF /* qrcode.png in Resources */,
D272A8D31FDA66220075DB1D /* arrow_right@2x.png in Resources */,
D29758601FE23DCD004314CF /* justifyContent.xml in Resources */,
D29D0D59221BEA2500DE5543 /* TestFrameView.xml in Resources */,
D2208DCF2205937400B6819E /* TestXmlView.xml in Resources */,
D24F2EAD1FF3C2D000762ADC /* TableHeader.xml in Resources */,
D2CF9CC11FD7EB0900554A0C /* return@2x.png in Resources */,
Expand Down Expand Up @@ -919,6 +928,7 @@
D297585E1FE22CF2004314CF /* DemoFlexVC.m in Sources */,
6003F59E195388D20070C39A /* FlexAppDelegate.m in Sources */,
D272A8C21FD933710075DB1D /* TestScrollVC.m in Sources */,
D29D0D57221BE9B400DE5543 /* TestFrameView.m in Sources */,
D272A8E01FDC0DD90075DB1D /* TestLoginVC.m in Sources */,
D24F2EBF1FF687C400762ADC /* AttachmentView.m in Sources */,
D2CF9CD01FD7EB1A00554A0C /* TestTableVC.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
9 changes: 9 additions & 0 deletions Example/FlexLib/FlexViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#import "ControlsVC.h"
#import "FrameVC.h"
#import "TestCollectionViewVC.h"
#import "TestFrameView.h"

@interface FlexViewController ()
{
Expand Down Expand Up @@ -82,4 +83,12 @@ -(void)onExplorerFlex
{
[FlexHttpVC presentInVC:self];
}
-(void)onFrameView
{
CGRect rcFrame = [[UIScreen mainScreen]bounds];
rcFrame.origin.y = 100;
rcFrame.size.height = 500;
TestFrameView* frameview=[[TestFrameView alloc]initWithFlex:nil Frame:rcFrame Owner:nil];
[self.view addSubview:frameview];
}
@end
17 changes: 17 additions & 0 deletions Example/FlexLib/TestFrameView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// TestFrameView.h
// FlexLib_Example
//
// Created by 郑立宝 on 2019/2/19.
// Copyright © 2019年 zhenglibao. All rights reserved.
//

#import <FlexLib/FlexLib.h>

NS_ASSUME_NONNULL_BEGIN

@interface TestFrameView : FlexFrameView

@end

NS_ASSUME_NONNULL_END
61 changes: 61 additions & 0 deletions Example/FlexLib/TestFrameView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// TestFrameView.m
// FlexLib_Example
//
// Created by 郑立宝 on 2019/2/19.
// Copyright © 2019年 zhenglibao. All rights reserved.
//
// Describe

#import "TestFrameView.h"

@interface TestFrameView()
{
UIView* _attachParent;
}
@end

@implementation TestFrameView

-(void)onClose
{
[self removeFromSuperview];
}
-(void)removeCell:(UIGestureRecognizer*)sender
{
UIView* cell = sender.view;
[cell removeFromSuperview];
[_attachParent markDirty];
}
-(void)onAddAttachment
{
UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(removeCell:)];
UIView* cell = [[UIView alloc]init];

[_attachParent addSubview:cell];

[cell enableFlexLayout:YES];
[cell addGestureRecognizer:tap];
[cell setLayoutAttrStrings:@[
@"width",@"80%",
@"height",@"44",
@"marginTop",@"5",
@"marginBottom",@"5",
@"alignItems",@"center",
@"justifyContent",@"center",
]];
[cell setViewAttr:@"bgColor" Value:@"#e5e5e5"];

UILabel* label=[UILabel new];
[cell addSubview:label];
[label enableFlexLayout:YES];
[label setViewAttrStrings:@[
@"fontSize",@"16",
@"color",@"red",
@"text",@"点我删除",
]];

[_attachParent markDirty];
}

@end
2 changes: 2 additions & 0 deletions Example/FlexLib/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
*/

"multilangdemo" = "This string is multi-language demo. You can change system language to see the effect. This example only support English & Chinese.";
"uilabellang" = "This is Richtext UILabel control(Multi-language support),";

11 changes: 11 additions & 0 deletions Example/FlexLib/res/FlexViewController.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,16 @@
</FlexTouchView>
</UIView>

<UIView layout="width:100%,flexDirection:row">
<FlexTouchView onPress="onFrameView" layout="@:system/button" attr="@:system/buttonAttr">
<UILabel
attr="@:system/buttonText,text:FrameView"/>
</FlexTouchView>
<!-- <FlexTouchView onPress="onExplorerFlex" layout="@:system/button" attr="@:system/buttonAttr">-->
<!-- <UILabel-->
<!-- attr="@:system/buttonText,text:"/>-->
<!-- </FlexTouchView>-->
</UIView>

</FlexScrollView>
</UIView>
12 changes: 12 additions & 0 deletions Example/FlexLib/res/TestFrameView.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 最外层的名字必须与组件的类名保持一致, 在xml中使用时设置的layout和attr属性会覆盖本xml中最外层的layout和attr -->
<FlexScrollView layout="flex:1,margin:50" attr="vertScroll:true,bgColor:lightGray,borderColor:red,borderWidth:1,borderRadius:5">
<UILabel attr="fontSize:16,color:#333333,linesNum:0,text:这是一个基于FlexFrameView的组件,不能使用在xml中,只能通过传统的initWithFrame方式创建并存取frame,与FlexCustomBaseView相比可以减少视图层级"/>
<FlexContainerView name="_attachParent" layout="marginTop:5,marginBottom:5,alignItems:center"/>
<FlexTouchView onPress="onAddAttachment" attr="underlayColor:#e5e5e5">
<UIImageView layout="" attr="source:select.png"/>
</FlexTouchView>
<FlexTouchView onPress="onClose" layout="alignItems:center" attr="underlayColor:#e5e5e5">
<UILabel layout="" attr="text:关闭"/>
</FlexTouchView>
</FlexScrollView>
2 changes: 1 addition & 1 deletion Example/FlexLib/res/TestScrollVC.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<UIView layout="height:20"/>
<UIView layout="padding:10,width:100%" attr="@:system/border">
<UILabel name="attrLabel" layout="width:100%" attr="linesNum:0,lineSpacing:20">
<Text name="a1" onPress="tapText:" attr="text:这是一个富文本的UILabel控件,font:system|18"/>
<Text name="a1" onPress="tapText:" attr="text:@uilabellang,font:system|18"/>
<Text onPress="tapText:" attr="text:粗体粗体粗体粗体粗体,font:bold|22"/>
<Text name="a2" onPress="tapText:" attr="text:斜体斜体斜体斜体斜体斜体斜体,font:italic|12,color:red,bgColor:green"/>
<Image name="a3" onPress="tapText:" attr="source:addnewtype.png,size:80/80"/>
Expand Down
1 change: 1 addition & 0 deletions Example/FlexLib/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

"multilangdemo" = "这条字符串用来展示多语言支持能力,你可以切换系统语言来看看效果,这个demo仅支持中文和英文";
"uilabellang" = "这是一个富文本的UILabel控件(支持多语言),";
20 changes: 20 additions & 0 deletions Example/FlexSwiftDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
D272B78B1FEF6770004447E2 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D272B78D1FEF6770004447E2 /* Localizable.strings */; };
D28F173020087B3100F5AEB2 /* Controls.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28F172F20087B3100F5AEB2 /* Controls.swift */; };
D28F173220087EEB00F5AEB2 /* Controls.xml in Resources */ = {isa = PBXBuildFile; fileRef = D28F173120087EEB00F5AEB2 /* Controls.xml */; };
D29D0D5B221BEF0700DE5543 /* TestFrameView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D29D0D5A221BEF0700DE5543 /* TestFrameView.swift */; };
D29D0D60221BF14400DE5543 /* TestFrameView.xml in Resources */ = {isa = PBXBuildFile; fileRef = D29D0D5C221BF14300DE5543 /* TestFrameView.xml */; };
D29D0D61221BF14400DE5543 /* TableHeader.xml in Resources */ = {isa = PBXBuildFile; fileRef = D29D0D5D221BF14400DE5543 /* TableHeader.xml */; };
D29D0D62221BF14400DE5543 /* TestXmlView.xml in Resources */ = {isa = PBXBuildFile; fileRef = D29D0D5E221BF14400DE5543 /* TestXmlView.xml */; };
D29D0D63221BF14400DE5543 /* AttachmentView.xml in Resources */ = {isa = PBXBuildFile; fileRef = D29D0D5F221BF14400DE5543 /* AttachmentView.xml */; };
D2D0206A1FEBA946008F6DB6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D020691FEBA946008F6DB6 /* AppDelegate.swift */; };
D2D0206C1FEBA946008F6DB6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2D0206B1FEBA946008F6DB6 /* ViewController.swift */; };
D2D020711FEBA946008F6DB6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D2D020701FEBA946008F6DB6 /* Assets.xcassets */; };
Expand Down Expand Up @@ -63,6 +68,11 @@
D272B78E1FEF6774004447E2 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
D28F172F20087B3100F5AEB2 /* Controls.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Controls.swift; sourceTree = "<group>"; };
D28F173120087EEB00F5AEB2 /* Controls.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = Controls.xml; path = FlexSwiftDemo/res/Controls.xml; sourceTree = SOURCE_ROOT; };
D29D0D5A221BEF0700DE5543 /* TestFrameView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestFrameView.swift; sourceTree = "<group>"; };
D29D0D5C221BF14300DE5543 /* TestFrameView.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = TestFrameView.xml; path = FlexSwiftDemo/res/TestFrameView.xml; sourceTree = SOURCE_ROOT; };
D29D0D5D221BF14400DE5543 /* TableHeader.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = TableHeader.xml; path = FlexSwiftDemo/res/TableHeader.xml; sourceTree = SOURCE_ROOT; };
D29D0D5E221BF14400DE5543 /* TestXmlView.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = TestXmlView.xml; path = FlexSwiftDemo/res/TestXmlView.xml; sourceTree = SOURCE_ROOT; };
D29D0D5F221BF14400DE5543 /* AttachmentView.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = AttachmentView.xml; path = FlexSwiftDemo/res/AttachmentView.xml; sourceTree = SOURCE_ROOT; };
D2D020661FEBA946008F6DB6 /* FlexSwiftDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FlexSwiftDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
D2D020691FEBA946008F6DB6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
D2D0206B1FEBA946008F6DB6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -169,6 +179,7 @@
D2D020B31FEC9B53008F6DB6 /* TestJustifycontentVC.swift */,
D2D020B51FECB39C008F6DB6 /* TestTableCell.swift */,
D2E0E2AA22059AC800D24288 /* TestXmlView.swift */,
D29D0D5A221BEF0700DE5543 /* TestFrameView.swift */,
D28F172F20087B3100F5AEB2 /* Controls.swift */,
D272B78D1FEF6770004447E2 /* Localizable.strings */,
);
Expand All @@ -179,6 +190,10 @@
isa = PBXGroup;
children = (
D2E0E2A822059A9E00D24288 /* TestXmlView.xml */,
D29D0D5F221BF14400DE5543 /* AttachmentView.xml */,
D29D0D5D221BF14400DE5543 /* TableHeader.xml */,
D29D0D5C221BF14300DE5543 /* TestFrameView.xml */,
D29D0D5E221BF14400DE5543 /* TestXmlView.xml */,
D2E8049720280D9200B54656 /* FrameVC.xml */,
D28F173120087EEB00F5AEB2 /* Controls.xml */,
D24F2EC21FF72CEB00762ADC /* AttachmentView.xml */,
Expand Down Expand Up @@ -271,12 +286,15 @@
files = (
D2E0E2A922059A9E00D24288 /* TestXmlView.xml in Resources */,
D24F2EAF1FF3CEB000762ADC /* TableHeader.xml in Resources */,
D29D0D60221BF14400DE5543 /* TestFrameView.xml in Resources */,
D2D020971FEBB289008F6DB6 /* return@2x.png in Resources */,
D29D0D63221BF14400DE5543 /* AttachmentView.xml in Resources */,
D2D020951FEBB289008F6DB6 /* example1.jpg in Resources */,
D2D0209B1FEBB289008F6DB6 /* batchcheck@2x.png in Resources */,
D2D0209E1FEBB289008F6DB6 /* TextViewVC.xml in Resources */,
D2D020991FEBB289008F6DB6 /* alignItems.xml in Resources */,
D2D020A41FEBB289008F6DB6 /* system.style in Resources */,
D29D0D61221BF14400DE5543 /* TableHeader.xml in Resources */,
D2D020A01FEBB289008F6DB6 /* justifyContent.xml in Resources */,
D2D020981FEBB289008F6DB6 /* TestScrollVC.xml in Resources */,
D2D020961FEBB289008F6DB6 /* TestModalVC.xml in Resources */,
Expand All @@ -291,6 +309,7 @@
D28F173220087EEB00F5AEB2 /* Controls.xml in Resources */,
D2D0209A1FEBB289008F6DB6 /* ViewController.xml in Resources */,
D2D020A61FEBB289008F6DB6 /* test.xml in Resources */,
D29D0D62221BF14400DE5543 /* TestXmlView.xml in Resources */,
D2D020711FEBA946008F6DB6 /* Assets.xcassets in Resources */,
D2D0209C1FEBB289008F6DB6 /* TestTableCell.xml in Resources */,
D2D020A31FEBB289008F6DB6 /* splash.png in Resources */,
Expand Down Expand Up @@ -349,6 +368,7 @@
files = (
D2E0E2AB22059AC800D24288 /* TestXmlView.swift in Sources */,
D2D020B21FEC9B31008F6DB6 /* TestTextviewVC.swift in Sources */,
D29D0D5B221BEF0700DE5543 /* TestFrameView.swift in Sources */,
D28F173020087B3100F5AEB2 /* Controls.swift in Sources */,
D2D020AE1FEC9A00008F6DB6 /* TestModalVC.swift in Sources */,
D2D020B61FECB39C008F6DB6 /* TestTableCell.swift in Sources */,
Expand Down
59 changes: 59 additions & 0 deletions Example/FlexSwiftDemo/TestFrameView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// TestFrameView.swift
// FlexSwiftDemo
//
// Created by 郑立宝 on 2019/2/19.
// Copyright © 2019年 wbg. All rights reserved.
//

import Foundation
import FlexLib

@objc(TestFrameView)
class TestFrameView: FlexFrameView {

@objc var _attachParent : UIView!

@objc(onClose)
func onClose()->Void{
self.removeFromSuperview()
}

@objc(removeCell:)
func removeCell(sender : UIGestureRecognizer) -> Void {
let cell = sender.view!
cell.removeFromSuperview()
_attachParent.markDirty()
}

@objc
func onAddAttachment() -> Void {
let tap = UITapGestureRecognizer.init(target: self, action: #selector(AttachmentView.removeCell(sender:)))
let cell = UIView()
cell.enableFlexLayout(true)
cell.addGestureRecognizer(tap)
cell.setLayoutAttrStrings([
"width","80%",
"height","44",
"marginTop","5",
"marginBottom","5",
"alignItems","center",
"justifyContent","center",
])

cell.setViewAttr("bgColor", value: "#e5e5e5")
_attachParent.addSubview(cell)

let label = UILabel()
label.enableFlexLayout(true)
label.setViewAttrStrings([
"fontSize","16",
"color","red",
"text","点我删除",
])
cell.addSubview(label)

_attachParent.markDirty()
}

}
7 changes: 7 additions & 0 deletions Example/FlexSwiftDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ class ViewController: FlexBaseVC {
@objc func onExplorerFlex()->Void{
FlexHttpVC.present(inVC: self)
}
@objc func onFrameView()->Void{
var frame = UIScreen.main.bounds;
frame.origin.y = 100
frame.size.height=400
let view = TestFrameView.init(flex: nil, frame: frame, owner: nil)
self.view.addSubview(view!)
}

}

12 changes: 12 additions & 0 deletions Example/FlexSwiftDemo/res/TestFrameView.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 最外层的名字必须与组件的类名保持一致, 在xml中使用时设置的layout和attr属性会覆盖本xml中最外层的layout和attr -->
<FlexScrollView layout="flex:1,margin:50" attr="vertScroll:true,bgColor:lightGray,borderColor:red,borderWidth:1,borderRadius:5">
<UILabel attr="fontSize:16,color:#333333,linesNum:0,text:这是一个基于FlexFrameView的组件,不能使用在xml中,只能通过传统的initWithFrame方式创建并存取frame,与FlexCustomBaseView相比可以减少视图层级"/>
<FlexContainerView name="_attachParent" layout="marginTop:5,marginBottom:5,alignItems:center"/>
<FlexTouchView onPress="onAddAttachment" attr="underlayColor:#e5e5e5">
<UIImageView layout="" attr="source:select.png"/>
</FlexTouchView>
<FlexTouchView onPress="onClose" layout="alignItems:center" attr="underlayColor:#e5e5e5">
<UILabel layout="" attr="text:关闭"/>
</FlexTouchView>
</FlexScrollView>
Loading

0 comments on commit e431cf0

Please sign in to comment.