Skip to content

Commit c97c67b

Browse files
author
xingbin
committed
target
1 parent 57505a7 commit c97c67b

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11

22
Pods/
33
Podfile.lock
4+
5+
MDLayout.xcworkspace/xcuserdata/jayden.xcuserdatad/UserInterfaceState.xcuserstate

MDLayout/Layout/MDLayoutContext.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ +(UIView *)loadViewWithXMLElement:(RXMLElement *)element styleSheet:(MDStyleshee
5757
NSArray *names = e.attributeNames;
5858
NSString *viewId = [e attribute:@"id"];
5959

60-
//应用样式
60+
//应用类样式
61+
MDStyle *style = styleSheet.targetStyleSheet[ename];
62+
if (style) {
63+
[currentView applyStyle:style];
64+
}
65+
66+
//应用指定样式
6167
NSString *styleName= [e attribute:@"style"];
6268
if (styleName) {
63-
MDStyle *style = styleSheet.styleSheet[styleName];
69+
style = styleSheet.styleSheet[styleName];
6470
if (style) {
6571
[currentView applyStyle:style];
6672
}

MDLayoutSample/MDLayoutSample/demo.xml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
<View>
1+
<Page>
22
<Resources>
33
<Stylesheet ref="styleRef.xml">
44
<Style name="pageStyle">
55
<Setter property="backgroundColor" value="#7F7F7F" />
66
</Style>
7+
<Style name="textStyle" target="UILabel">
8+
<Setter property="textColor" value="#4455ff" />
9+
</Style>
10+
711
<Style name="textHeaderStyle" target="">
8-
<Setter property="textColor" value="#000000" />
12+
<Setter property="textColor" value="black" />
913
<Setter property="backgroundColor" value="green" />
1014
<Setter property="font" value="SegoeUI-Bold 20" />
1115
</Style>
1216
<Style name="buttonStyle">
13-
<Setter property="titleforNormalState" value="on my g" />
17+
<Setter property="titleforNormalState" value="on my god" />
1418
<Setter property="titleforSelectedState" value="click me" />
1519
<Setter property="selected" value="YES" />
1620
<Setter property="layer.cornerRadius" value="2" />
@@ -41,7 +45,7 @@
4145
<Constraint attribute="right" target="containner" relation="=" constant="-10" id="right"/>
4246
</Constraints>
4347
</UILabel>
44-
<UIButton id="centerButton" mdoutlet="YES" buttonType="UIButtonTypeCustom" clickAction="centerButton_click:" style="buttonStyle">
48+
<UIButton id="centerButton" mdoutlet="YES" clickAction="centerButton_click:" style="buttonStyle">
4549
<Constraints>
4650
<Constraint attribute="width" relation="=" target="containner" targetAttribute="width" multipliedBy="0.8" id="width"/>
4751
<Constraint attribute="height" relation="=" constant="200" id="height"/>
@@ -57,4 +61,4 @@
5761
</UILabel>
5862
</DemoHostView>
5963
</Layout>
60-
</View>
64+
</Page>

MDLayoutSample/MDLayoutSample/styleRef.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<Style name="bottomLableStyle">
44
<Setter property="textColor" value="red" />
55
<Setter property="font" value="SegoeUI-Bold 25" />
6-
<Setter property="backgroundColor" value="yellow" />
6+
<Setter property="backgroundColor" value="yellow" />
77
</Style>
88
</Stylesheet>

0 commit comments

Comments
 (0)