Skip to content

Commit 884c2ee

Browse files
committed
支持调整 header 部分的间距
1 parent 4756a7a commit 884c2ee

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

Example/TBAlertControllerDemo/ConditionerView.xib

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
33
<device id="retina5_5" orientation="portrait">
44
<adaptation id="fullscreen"/>
55
</device>
66
<dependencies>
77
<deployment identifier="iOS"/>
8-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<objects>
@@ -15,20 +15,20 @@
1515
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
1616
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1717
<subviews>
18-
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="按钮高度" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="haQ-d8-9b8">
19-
<rect key="frame" x="8" y="8" width="69.333333333333329" height="30"/>
18+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="按钮高度(下次生效)" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="haQ-d8-9b8">
19+
<rect key="frame" x="8" y="8" width="173.33333333333334" height="30"/>
2020
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2121
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2222
<nil key="highlightedColor"/>
2323
</label>
2424
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="按钮宽度" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9C2-jg-wKE">
25-
<rect key="frame" x="8" y="46" width="69.333333333333329" height="29"/>
25+
<rect key="frame" x="8" y="46" width="69.333333333333329" height="30"/>
2626
<fontDescription key="fontDescription" type="system" pointSize="17"/>
2727
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2828
<nil key="highlightedColor"/>
2929
</label>
3030
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Y偏移量" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gSM-2S-Dxa">
31-
<rect key="frame" x="8" y="83" width="63" height="31"/>
31+
<rect key="frame" x="8" y="84" width="63" height="30"/>
3232
<fontDescription key="fontDescription" type="system" pointSize="17"/>
3333
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
3434
<nil key="highlightedColor"/>
@@ -46,13 +46,13 @@
4646
<nil key="highlightedColor"/>
4747
</label>
4848
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="矩形圆角半径" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ev7-5a-npH">
49-
<rect key="frame" x="8" y="200" width="104" height="29"/>
49+
<rect key="frame" x="8" y="200" width="104" height="30"/>
5050
<fontDescription key="fontDescription" type="system" pointSize="17"/>
5151
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
5252
<nil key="highlightedColor"/>
5353
</label>
5454
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="动画持续时长" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qSa-Ek-8De">
55-
<rect key="frame" x="8" y="237" width="104" height="31"/>
55+
<rect key="frame" x="8" y="238" width="104" height="30"/>
5656
<fontDescription key="fontDescription" type="system" pointSize="17"/>
5757
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
5858
<nil key="highlightedColor"/>

Source/TBActionSheet/TBActionSheet.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,29 @@ NS_ASSUME_NONNULL_BEGIN
176176
按钮之间的小间隙,default = 0.5
177177
*/
178178
@property (nonatomic) CGFloat smallFragment UI_APPEARANCE_SELECTOR;
179+
180+
/**
181+
--------------------------
182+
headerVerticalSpacing
183+
--------------------------
184+
title
185+
--------------------------
186+
headerLineSpacing
187+
--------------------------
188+
message
189+
--------------------------
190+
headerVerticalSpacing
191+
--------------------------
192+
*/
193+
179194
/**
180195
header 文字的纵向留白
181196
*/
182-
@property (nonatomic) CGFloat headerVerticalSpace UI_APPEARANCE_SELECTOR;
197+
@property (nonatomic) CGFloat headerVerticalSpacing UI_APPEARANCE_SELECTOR;
198+
/**
199+
title 与 message 文字的行距
200+
*/
201+
@property (nonatomic) CGFloat headerLineSpacing UI_APPEARANCE_SELECTOR;
183202
/**
184203
ActionSheet 内容超出屏幕后是否开启滚动,默认为 YES
185204
*/

Source/TBActionSheet/TBActionSheet.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#import "UIWindow+TBAdditions.h"
1515
#import "UIView+TBAdditions.h"
1616

17-
const CGFloat headerVerticalSpace = 10;
1817
const CGFloat blurRadius = 0.7;
1918

2019
typedef void (^TBBlurEffectBlock)(void);
@@ -73,6 +72,7 @@ + (void)initialize
7372
appearance.animationVelocity = 1;
7473
appearance.supportedInterfaceOrientations = UIInterfaceOrientationMaskAll;
7574
appearance.scrollEnabled = YES;
75+
appearance.headerVerticalSpacing = 10;
7676
}
7777

7878
- (instancetype)init
@@ -385,7 +385,7 @@ - (void)setupLayout
385385

386386
//处理标题
387387
if ([self hasTitle]) {
388-
lastY += headerVerticalSpace;
388+
lastY += self.headerVerticalSpacing;
389389
self.titleLabel.frame = CGRectMake(0, lastY, self.sheetWidth, 0);
390390
[self.actionContainer.header addSubview:self.titleLabel];
391391
self.titleLabel.text = self.title;
@@ -394,7 +394,10 @@ - (void)setupLayout
394394
//处理 message
395395
if ([self hasMessage]) {
396396
if (![self hasTitle]) {
397-
lastY += headerVerticalSpace;
397+
lastY += self.headerVerticalSpacing;
398+
}
399+
else {
400+
lastY += self.headerLineSpacing;
398401
}
399402
self.messageLabel.frame = CGRectMake(0, lastY, self.sheetWidth, 0);
400403
[self.actionContainer.header addSubview:self.messageLabel];
@@ -404,7 +407,7 @@ - (void)setupLayout
404407

405408
//处理title
406409
if ([self hasHeader]) {
407-
lastY += headerVerticalSpace;
410+
lastY += self.headerVerticalSpacing;
408411
self.actionContainer.header.frame = CGRectMake(0, 0, self.sheetWidth, lastY);
409412
}
410413

TBActionSheet.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "TBActionSheet"
3-
s.version = "1.7.3"
3+
s.version = "1.7.4"
44
s.summary = "A Custom&Magical ActionSheet."
55
s.description = <<-DESC
66
TBActionSheet is a small library that allows you to substitute Apple's uncustomizable UIActionSheet, with a beautiful and totally customizable actionsheet that you can use in your iOS app. The default style is iOS9/10, you can make your own style. Enjoy!

0 commit comments

Comments
 (0)