Skip to content

Commit

Permalink
Expose lineColor
Browse files Browse the repository at this point in the history
Updated example to show usage with Dark Mode
  • Loading branch information
nighthawk committed Sep 13, 2019
1 parent 14558b0 commit c3927a1
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 30 deletions.
4 changes: 2 additions & 2 deletions ASWeekSelectorView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ASWeekSelectorView"
s.version = "1.0.3"
s.version = "1.0.4"
s.summary = "iOS calendar-inspired simple mini week view to select swipe through weeks and tap on days"
s.description = <<-DESC
A mini week view to select a day. You can swipe through weeks and tap on days to select them, somewhat similar to the iOS 7 calendar app.
Expand All @@ -10,7 +10,7 @@ Pod::Spec.new do |s|
s.author = { "Adrian Schoenig" => "adrian.schoenig@gmail.com" }
# s.source = { git: '.'}
s.source = { :git => "https://github.com/nighthawk/ASWeekSelectorView.git", :tag => "v#{s.version}" }
s.platform = :ios, '7.0'
s.platform = :ios, '9.3'
s.source_files = 'Classes/*.{h,m}'
s.requires_arc = true
end
5 changes: 5 additions & 0 deletions Classes/ASWeekSelectorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, strong) UIColor *letterTextColor;

/**
Color used for the various separators at the bottom of the view and between days
*/
@property (nonatomic, strong) UIColor *lineColor;

/**
Locale used for formatting dates
@default `autoupdatingCurrentLocale`
Expand Down
5 changes: 2 additions & 3 deletions Classes/ASWeekSelectorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ @interface ASWeekSelectorView () <ASSingleWeekViewDelegate, UIScrollViewDelegate
// formatting
@property (nonatomic, strong) UIColor *selectorLetterTextColor;
@property (nonatomic, strong) UIColor *selectorBackgroundColor;
@property (nonatomic, strong) UIColor *lineColor;

@end

Expand Down Expand Up @@ -358,8 +357,8 @@ - (void)didInit:(BOOL)setDefaults
_letterTextColor = [UIColor colorWithWhite:204.f/255 alpha:1];
_numberTextColor = [UIColor colorWithWhite:77.f/255 alpha:1];
_lineColor = [UIColor colorWithWhite:245.f/255 alpha:1];
_selectorBackgroundColor = [UIColor whiteColor];
_selectorLetterTextColor = [UIColor whiteColor];
_selectorBackgroundColor = self.backgroundColor;
_selectorLetterTextColor = self.backgroundColor;
_preDragOffsetX = MAXFLOAT;
_preDragSelectionX = MAXFLOAT;
_locale = [NSLocale autoupdatingCurrentLocale];
Expand Down
29 changes: 24 additions & 5 deletions Example/ASWeekSelectorView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = AS;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Adrian Schoenig";
TargetAttributes = {
3AAC012818FE027600EBD85D = {
Expand All @@ -312,6 +312,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -431,18 +432,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -465,7 +475,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
Expand All @@ -475,18 +485,27 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand All @@ -502,7 +521,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
Expand All @@ -516,6 +535,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ASWeekSelectorView/ASWeekSelectorView-Prefix.pch";
INFOPLIST_FILE = "ASWeekSelectorView/ASWeekSelectorView-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "net.byadrian.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -531,6 +551,7 @@
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "ASWeekSelectorView/ASWeekSelectorView-Prefix.pch";
INFOPLIST_FILE = "ASWeekSelectorView/ASWeekSelectorView-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "net.byadrian.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -598,7 +619,6 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ASWeekSelectorView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.buzzhives.ASWeekSelectorView;
Expand Down Expand Up @@ -627,7 +647,6 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = ASWeekSelectorView/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = com.buzzhives.ASWeekSelectorView;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0830"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -29,8 +29,6 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -51,8 +49,6 @@
ReferencedContainer = "container:ASWeekSelectorView.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
8 changes: 5 additions & 3 deletions Example/ASWeekSelectorView/ASViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ - (void)viewDidLoad
[self updateLabelForDate:now];

self.weekSelector.firstWeekday = 2; // monday
self.weekSelector.letterTextColor = [UIColor colorWithWhite:.5 alpha:1];
self.weekSelector.letterTextColor = UIColor.labelColor;
self.weekSelector.numberTextColor = UIColor.labelColor;
self.weekSelector.lineColor = UIColor.separatorColor;
self.weekSelector.delegate = self;
self.weekSelector.selectedDate = now;
}
Expand All @@ -67,7 +69,7 @@ - (UIColor *)weekSelector:(ASWeekSelectorView *)weekSelector numberColorForDate:
NSCalendar *gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
NSInteger weekday = [gregorian component:NSCalendarUnitWeekday fromDate:date];
if (weekday == 1 || weekday == 7) { // Sat or Sun
return [UIColor lightGrayColor];
return UIColor.secondaryLabelColor;
} else {
return nil;
}
Expand All @@ -78,7 +80,7 @@ - (UIColor *)weekSelector:(ASWeekSelectorView *)weekSelector circleColorForDate:
NSCalendar *gregorian = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
NSInteger weekday = [gregorian component:NSCalendarUnitWeekday fromDate:date];
if (weekday == 2) { // Mo
return [UIColor greenColor];
return [UIColor systemGreenColor];
} else {
return nil;
}
Expand Down
25 changes: 13 additions & 12 deletions Example/ASWeekSelectorView/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="RCR-5L-KLf">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="RCR-5L-KLf">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14824"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="dIf-C7-Kd1">
<objects>
<navigationController definesPresentationContext="YES" id="RCR-5L-KLf" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" id="tdQ-zT-ZcA">
<rect key="frame" x="0.0" y="44" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<connections>
Expand All @@ -19,7 +21,7 @@
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="cEk-qH-NhT" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-549" y="-444"/>
<point key="canvasLocation" x="-795.6521739130435" y="-297.32142857142856"/>
</scene>
<!--Example-->
<scene sceneID="ufC-wZ-h7g">
Expand All @@ -30,24 +32,23 @@
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cfS-TK-ad1" customClass="ASWeekSelectorView">
<rect key="frame" x="0.0" y="64" width="320" height="60"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<rect key="frame" x="0.0" y="88" width="414" height="60"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="height" constant="60" id="07K-Ez-cvt"/>
</constraints>
</view>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="w9l-8I-EIJ">
<rect key="frame" x="16" y="273" width="288" height="21"/>
<rect key="frame" x="20" y="297" width="374" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="cfS-TK-ad1" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" id="DVr-57-CRr"/>
<constraint firstAttribute="trailingMargin" secondItem="w9l-8I-EIJ" secondAttribute="trailing" id="HtN-Sx-3Vb"/>
Expand All @@ -71,7 +72,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="111" y="-444"/>
<point key="canvasLocation" x="160.86956521739131" y="-297.32142857142856"/>
</scene>
</scenes>
</document>

0 comments on commit c3927a1

Please sign in to comment.