Skip to content

Commit 406bb02

Browse files
committed
Change HeaderView layout
1 parent b45af0f commit 406bb02

File tree

10 files changed

+97
-45
lines changed

10 files changed

+97
-45
lines changed

DLWeiboProfileController/.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "userAvatar.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
23 KB
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "userAvatar.png",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"version" : 1,
19+
"author" : "xcode"
20+
}
21+
}
136 KB
Loading

DLWeiboProfileController/DLWeiboProfileController/View/DLUserHeaderView.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
@interface DLUserHeaderView()
1414

15+
@property (weak, nonatomic) IBOutlet UIImageView *userAvatarImageView;
1516

1617

1718

@@ -24,6 +25,15 @@ +(DLUserHeaderView *)userHeaderView
2425
return [[[NSBundle mainBundle] loadNibNamed:@"DLUserHeaderView" owner:nil options:nil] firstObject];
2526
}
2627

28+
-(void)awakeFromNib
29+
{
30+
[super awakeFromNib];
31+
self.userAvatarImageView.layer.cornerRadius = 80 / 2.0;
32+
self.userAvatarImageView.layer.borderWidth = 1;
33+
self.userAvatarImageView.layer.borderColor = [UIColor whiteColor].CGColor;
34+
self.userAvatarImageView.layer.masksToBounds = YES;
35+
}
36+
2737
- (IBAction)tapOnImageView:(id)sender {
2838
if (self.delegate && [self.delegate respondsToSelector:@selector(userHeaderViewButtonDidClick:)]) {
2939
[self.delegate userHeaderViewButtonDidClick:self];

DLWeiboProfileController/DLWeiboProfileController/View/DLUserHeaderView.xib

Lines changed: 41 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,62 +12,59 @@
1212
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
1313
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
1414
<view contentMode="scaleToFill" id="iN0-l3-epB" customClass="DLUserHeaderView">
15-
<rect key="frame" x="0.0" y="0.0" width="375" height="280"/>
15+
<rect key="frame" x="0.0" y="0.0" width="375" height="226"/>
1616
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717
<subviews>
18-
<imageView clipsSubviews="YES" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallPaper3" translatesAutoresizingMaskIntoConstraints="NO" id="7Nq-Pz-OQm">
19-
<rect key="frame" x="0.0" y="0.0" width="375" height="280"/>
18+
<imageView clipsSubviews="YES" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="wallPaper5" translatesAutoresizingMaskIntoConstraints="NO" id="7Nq-Pz-OQm">
19+
<rect key="frame" x="0.0" y="0.0" width="375" height="226"/>
2020
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
2121
<gestureRecognizers/>
2222
<connections>
2323
<outletCollection property="gestureRecognizers" destination="YLf-gL-Ox2" appends="YES" id="6wd-Te-lWr"/>
2424
</connections>
2525
</imageView>
26-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GRg-Oe-ccu">
27-
<rect key="frame" x="0.0" y="168" width="375" height="112"/>
28-
<subviews>
29-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="David" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rjv-TG-KhT">
30-
<rect key="frame" x="20" y="15" width="335" height="26.5"/>
31-
<fontDescription key="fontDescription" type="boldSystem" pointSize="22"/>
32-
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
33-
<nil key="highlightedColor"/>
34-
</label>
35-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Be nice and work hard!" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="soh-ng-tFR">
36-
<rect key="frame" x="20" y="49.5" width="335" height="18"/>
37-
<fontDescription key="fontDescription" type="system" pointSize="15"/>
38-
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
39-
<nil key="highlightedColor"/>
40-
</label>
41-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="iOS Developer" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YSo-WC-guW">
42-
<rect key="frame" x="20" y="72.5" width="198" height="18"/>
43-
<fontDescription key="fontDescription" type="system" pointSize="15"/>
44-
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
45-
<nil key="highlightedColor"/>
46-
</label>
47-
</subviews>
48-
<color key="backgroundColor" red="0.25880080461502075" green="0.25883632898330688" blue="0.25882352941176467" alpha="0.29999999999999999" colorSpace="custom" customColorSpace="sRGB"/>
26+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="David" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rjv-TG-KhT">
27+
<rect key="frame" x="20" y="138.5" width="335" height="23"/>
28+
<fontDescription key="fontDescription" type="boldSystem" pointSize="19"/>
29+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
30+
<nil key="highlightedColor"/>
31+
</label>
32+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Follow 469 | Follower 179" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="soh-ng-tFR">
33+
<rect key="frame" x="20" y="170" width="335" height="17"/>
34+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
35+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
36+
<nil key="highlightedColor"/>
37+
</label>
38+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="About: Be nice and work hard!" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YSo-WC-guW">
39+
<rect key="frame" x="20" y="195" width="335" height="17"/>
40+
<fontDescription key="fontDescription" type="system" pointSize="14"/>
41+
<color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
42+
<nil key="highlightedColor"/>
43+
</label>
44+
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="userAvatar-1" translatesAutoresizingMaskIntoConstraints="NO" id="72v-Pm-Nsm">
45+
<rect key="frame" x="147.5" y="50" width="80" height="80"/>
4946
<constraints>
50-
<constraint firstItem="soh-ng-tFR" firstAttribute="leading" secondItem="GRg-Oe-ccu" secondAttribute="leading" constant="20" id="BRl-hV-4b7"/>
51-
<constraint firstAttribute="trailing" secondItem="soh-ng-tFR" secondAttribute="trailing" constant="20" id="Eyl-nA-3TR"/>
52-
<constraint firstAttribute="height" constant="112" id="JWl-na-V5H"/>
53-
<constraint firstItem="rjv-TG-KhT" firstAttribute="leading" secondItem="GRg-Oe-ccu" secondAttribute="leading" constant="20" id="Q0q-As-fNe"/>
54-
<constraint firstItem="soh-ng-tFR" firstAttribute="top" secondItem="rjv-TG-KhT" secondAttribute="bottom" constant="8" id="Qbf-vs-vhW"/>
55-
<constraint firstAttribute="trailing" secondItem="YSo-WC-guW" secondAttribute="trailing" constant="157" id="ZDN-MF-4n2"/>
56-
<constraint firstItem="rjv-TG-KhT" firstAttribute="top" secondItem="GRg-Oe-ccu" secondAttribute="top" constant="15" id="clL-DV-mlk"/>
57-
<constraint firstItem="YSo-WC-guW" firstAttribute="top" secondItem="soh-ng-tFR" secondAttribute="bottom" constant="5" id="keu-HZ-Ag9"/>
58-
<constraint firstItem="YSo-WC-guW" firstAttribute="leading" secondItem="GRg-Oe-ccu" secondAttribute="leading" constant="20" id="mb0-FX-vGB"/>
59-
<constraint firstAttribute="trailing" secondItem="rjv-TG-KhT" secondAttribute="trailing" constant="20" id="mnD-Vh-anz"/>
47+
<constraint firstAttribute="width" constant="80" id="K4z-H1-Bmo"/>
48+
<constraint firstAttribute="height" constant="80" id="bwW-vJ-nO0"/>
6049
</constraints>
61-
</view>
50+
</imageView>
6251
</subviews>
6352
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
6453
<constraints>
54+
<constraint firstItem="soh-ng-tFR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="1P9-og-pDV"/>
6555
<constraint firstAttribute="bottom" secondItem="7Nq-Pz-OQm" secondAttribute="bottom" id="1hK-3E-AqM"/>
6656
<constraint firstAttribute="trailing" secondItem="7Nq-Pz-OQm" secondAttribute="trailing" id="5OS-OK-5H2"/>
6757
<constraint firstItem="7Nq-Pz-OQm" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="5aH-Ec-0ci"/>
68-
<constraint firstAttribute="trailing" secondItem="GRg-Oe-ccu" secondAttribute="trailing" id="Lcf-cV-BBW"/>
69-
<constraint firstAttribute="bottom" secondItem="GRg-Oe-ccu" secondAttribute="bottom" id="WEV-e4-7nM"/>
70-
<constraint firstItem="GRg-Oe-ccu" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="eEj-nq-8GA"/>
58+
<constraint firstItem="rjv-TG-KhT" firstAttribute="top" secondItem="72v-Pm-Nsm" secondAttribute="bottom" constant="8" id="7bq-aa-kk9"/>
59+
<constraint firstAttribute="bottom" secondItem="YSo-WC-guW" secondAttribute="bottom" constant="14" id="9Ze-a9-0hh"/>
60+
<constraint firstItem="rjv-TG-KhT" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="GQ6-rL-iil"/>
61+
<constraint firstAttribute="trailing" secondItem="YSo-WC-guW" secondAttribute="trailing" constant="20" id="IBC-kZ-wsk"/>
62+
<constraint firstItem="soh-ng-tFR" firstAttribute="top" secondItem="rjv-TG-KhT" secondAttribute="bottom" constant="8" id="JOL-2w-xRR"/>
63+
<constraint firstAttribute="trailing" secondItem="soh-ng-tFR" secondAttribute="trailing" constant="20" id="QUF-l2-UxD"/>
64+
<constraint firstItem="72v-Pm-Nsm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Vlm-JH-66s"/>
65+
<constraint firstAttribute="trailing" secondItem="rjv-TG-KhT" secondAttribute="trailing" constant="20" id="qHP-Ku-PMH"/>
66+
<constraint firstItem="YSo-WC-guW" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" id="rnd-b3-xRx"/>
67+
<constraint firstItem="YSo-WC-guW" firstAttribute="top" secondItem="soh-ng-tFR" secondAttribute="bottom" constant="8" id="ueW-9v-qpS"/>
7168
<constraint firstItem="7Nq-Pz-OQm" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="ypM-Iv-v9s"/>
7269
</constraints>
7370
<nil key="simulatedStatusBarMetrics"/>
@@ -76,9 +73,10 @@
7673
<outlet property="compayLabel" destination="soh-ng-tFR" id="U0K-7Z-Zsw"/>
7774
<outlet property="nameLabel" destination="rjv-TG-KhT" id="4Hq-bQ-XAK"/>
7875
<outlet property="roleLabel" destination="YSo-WC-guW" id="fxH-EP-wxj"/>
76+
<outlet property="userAvatarImageView" destination="72v-Pm-Nsm" id="cVr-Qt-OT1"/>
7977
<outlet property="userImageView" destination="7Nq-Pz-OQm" id="c96-lJ-EFQ"/>
8078
</connections>
81-
<point key="canvasLocation" x="199" y="-187"/>
79+
<point key="canvasLocation" x="-203" y="-225"/>
8280
</view>
8381
<tapGestureRecognizer id="YLf-gL-Ox2">
8482
<connections>
@@ -87,6 +85,7 @@
8785
</tapGestureRecognizer>
8886
</objects>
8987
<resources>
90-
<image name="wallPaper3" width="600" height="810"/>
88+
<image name="userAvatar-1" width="150" height="100"/>
89+
<image name="wallPaper5" width="600" height="415"/>
9190
</resources>
9291
</document>

DLWeiboProfileController/DLWeiboProfileController/View/DLUserPageNavBar.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ -(void)setDl_alpha:(CGFloat)dl_alpha
5555
{
5656
_dl_alpha = dl_alpha;
5757
self.backImageView.alpha = dl_alpha;
58-
self.nameLabel.hidden = !(dl_alpha >= 1.0);
58+
self.nameLabel.hidden = !(dl_alpha >= 0.99);
5959
}
6060

6161

DLWeiboProfileController/DLWeiboProfileController/ViewController/PersonalCenterController.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ -(void)dl_uiConfig
9191

9292
self.userHeaderView = [DLUserHeaderView userHeaderView];
9393
self.userHeaderView.delegate = self;
94-
self.userHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 1.34 );
94+
self.userHeaderView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_WIDTH / 1.7);
9595
_stretchableTableHeaderView = [HFStretchableTableHeaderView new];
9696
[_stretchableTableHeaderView stretchHeaderForTableView:self.tableView withView:self.userHeaderView];
9797
}
@@ -177,9 +177,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
177177

178178
//计算导航栏的透明度
179179
CGFloat minAlphaOffset = 0;
180-
CGFloat maxAlphaOffset = SCREEN_WIDTH / 1.34 - 64;
180+
CGFloat maxAlphaOffset = SCREEN_WIDTH / 1.7 - 64;
181181
CGFloat offset = scrollView.contentOffset.y;
182182
CGFloat alpha = (offset - minAlphaOffset) / (maxAlphaOffset - minAlphaOffset);
183+
NSLog(@"alpha--%f",alpha);
183184
self.userPageNavBar.dl_alpha = alpha;
184185

185186

0 commit comments

Comments
 (0)