-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UILabel支持国际化,FlexXmlBaseView支持代码方式创建,更新FrameView组件的例子
- Loading branch information
zhenglibao
committed
Feb 19, 2019
1 parent
526fabb
commit e431cf0
Showing
23 changed files
with
302 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Example/FlexLib.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.