浏览代码

首页资讯样式

Steven 6 月之前
父节点
当前提交
c9f933ad7c

+ 13 - 20
KulexiuForStudent/KulexiuForStudent/Module/Home/View/HomeInformationCell.m

@@ -17,6 +17,8 @@
 
 @property (weak, nonatomic) IBOutlet UIView *backView;
 
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomSpace;
+
 @end
 
 @implementation HomeInformationCell
@@ -32,32 +34,23 @@
     self.timeLabel.text = [model.createTime dateFormatString];
     [self.messageImage sd_setImageWithURL:[NSURL URLWithString:[model.coverImage getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:@"video_placeholder"]];
     if (rowIndex == ROWINDEX_TOP) {
-        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
-        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
-        maskLayer.frame = self.backView.bounds;
-        maskLayer.path = maskPath.CGPath;
-        self.backView.layer.mask = maskLayer;
+        self.backView.layer.cornerRadius = 10.0f;
+        self.backView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
+        self.bottomSpace.constant = 0.0f;
     }
     else if (rowIndex == ROWINDEX_BOTTOM) {
-        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
-        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
-        maskLayer.frame = self.backView.bounds;
-        maskLayer.path = maskPath.CGPath;
-        self.backView.layer.mask = maskLayer;
+        self.backView.layer.cornerRadius = 10.0f;
+        self.backView.layer.maskedCorners = kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
+        self.bottomSpace.constant = 20.0f;
     }
     else if (rowIndex == ROWINDEX_TOP_BOTTOM) {
-        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight|UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
-        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
-        maskLayer.frame = self.backView.bounds;
-        maskLayer.path = maskPath.CGPath;
-        self.backView.layer.mask = maskLayer;
+        self.backView.layer.cornerRadius = 10.0f;
+        self.backView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner |  kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner;
+        self.bottomSpace.constant = 20.0f;
     }
     else {
-        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, kScreenWidth - 28, 90) byRoundingCorners:UIRectCornerBottomLeft|UIRectCornerBottomRight cornerRadii:CGSizeMake(0, 0)];
-        CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
-        maskLayer.frame = self.backView.bounds;
-        maskLayer.path = maskPath.CGPath;
-        self.backView.layer.mask = maskLayer;
+        self.backView.layer.cornerRadius = 0.0f;
+        self.bottomSpace.constant = 0.0f;
     }
 }
 

+ 10 - 8
KulexiuForStudent/KulexiuForStudent/Module/Home/View/HomeInformationCell.xib

@@ -12,17 +12,17 @@
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
         <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="KGk-i7-Jjw" customClass="HomeInformationCell">
-            <rect key="frame" x="0.0" y="0.0" width="442" height="90"/>
+            <rect key="frame" x="0.0" y="0.0" width="442" height="100"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
             <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
-                <rect key="frame" x="0.0" y="0.0" width="442" height="90"/>
+                <rect key="frame" x="0.0" y="0.0" width="442" height="100"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="mV5-EQ-8aL">
-                        <rect key="frame" x="14" y="0.0" width="414" height="90"/>
+                        <rect key="frame" x="14" y="0.0" width="414" height="100"/>
                         <subviews>
                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="video_placeholder" translatesAutoresizingMaskIntoConstraints="NO" id="Z8V-5d-ftb">
-                                <rect key="frame" x="10" y="5" width="108" height="80"/>
+                                <rect key="frame" x="10" y="20" width="108" height="80"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="80" id="Ixx-fI-7pn"/>
                                     <constraint firstAttribute="width" constant="108" id="h7s-KS-fQD"/>
@@ -34,7 +34,7 @@
                                 </userDefinedRuntimeAttributes>
                             </imageView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2024年07月15日" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="7QX-lI-BO2">
-                                <rect key="frame" x="130" y="67" width="97" height="17"/>
+                                <rect key="frame" x="130" y="82" width="97" height="17"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="17" id="ect-XX-4v1"/>
                                 </constraints>
@@ -43,7 +43,7 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="交响乐团由哪些乐器组成?初学者如何迈过学" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="vYy-zu-7s3">
-                                <rect key="frame" x="130" y="6" width="270" height="36"/>
+                                <rect key="frame" x="130" y="22" width="270" height="36"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="15"/>
                                 <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <nil key="highlightedColor"/>
@@ -51,11 +51,12 @@
                         </subviews>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
-                            <constraint firstItem="Z8V-5d-ftb" firstAttribute="centerY" secondItem="mV5-EQ-8aL" secondAttribute="centerY" id="65T-Vc-Xyh"/>
+                            <constraint firstItem="Z8V-5d-ftb" firstAttribute="top" secondItem="mV5-EQ-8aL" secondAttribute="top" constant="20" id="1yE-8L-1mk"/>
                             <constraint firstAttribute="trailing" secondItem="vYy-zu-7s3" secondAttribute="trailing" constant="14" id="7U3-xg-AYH"/>
                             <constraint firstItem="Z8V-5d-ftb" firstAttribute="leading" secondItem="mV5-EQ-8aL" secondAttribute="leading" constant="10" id="AkI-85-N17"/>
                             <constraint firstItem="vYy-zu-7s3" firstAttribute="leading" secondItem="Z8V-5d-ftb" secondAttribute="trailing" constant="12" id="R3E-jc-iaM"/>
-                            <constraint firstItem="vYy-zu-7s3" firstAttribute="top" secondItem="Z8V-5d-ftb" secondAttribute="top" constant="1" id="kdL-xJ-5iv"/>
+                            <constraint firstAttribute="bottom" secondItem="Z8V-5d-ftb" secondAttribute="bottom" id="SyQ-7k-v1y"/>
+                            <constraint firstItem="vYy-zu-7s3" firstAttribute="top" secondItem="Z8V-5d-ftb" secondAttribute="top" constant="2" id="kdL-xJ-5iv"/>
                             <constraint firstItem="7QX-lI-BO2" firstAttribute="bottom" secondItem="Z8V-5d-ftb" secondAttribute="bottom" constant="-1" id="nvO-fK-ikj"/>
                             <constraint firstItem="7QX-lI-BO2" firstAttribute="leading" secondItem="Z8V-5d-ftb" secondAttribute="trailing" constant="12" id="rfR-4y-TIo"/>
                         </constraints>
@@ -73,6 +74,7 @@
             <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
             <connections>
                 <outlet property="backView" destination="mV5-EQ-8aL" id="ew1-Ax-ZPM"/>
+                <outlet property="bottomSpace" destination="SyQ-7k-v1y" id="KN1-Li-CM2"/>
                 <outlet property="messageImage" destination="Z8V-5d-ftb" id="jJy-y1-rPF"/>
                 <outlet property="messageTitle" destination="vYy-zu-7s3" id="A78-0z-65X"/>
                 <outlet property="timeLabel" destination="7QX-lI-BO2" id="L9Q-3J-Uzq"/>

+ 2 - 2
KulexiuForStudent/KulexiuForStudent/Module/Home/View/HomePageView/HomeInformationBodyView.m

@@ -33,8 +33,8 @@
         self.tableView.dataSource = self;
         self.tableView.delegate = self;
         self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
-        self.tableView.rowHeight = 90;
-        
+        self.tableView.rowHeight = UITableViewAutomaticDimension;
+        self.tableView.estimatedRowHeight = 100.0f;
         HomeInformationHeadView *headView = [HomeInformationHeadView sharedInstance];
         CGFloat height = [HomeInformationHeadView getViewHeight];
         headView.frame = CGRectMake(0, 0, KPortraitWidth, height);