Update macOS demo to add a clear cache button using NSButton category
This commit is contained in:
parent
634e4f4522
commit
7996b0dac8
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"version" : 1,
|
||||||
|
"author" : "xcode"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<deployment identifier="macosx"/>
|
<deployment identifier="macosx"/>
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="13771"/>
|
||||||
|
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<scenes>
|
<scenes>
|
||||||
<!--Application-->
|
<!--Application-->
|
||||||
|
@ -656,6 +657,9 @@
|
||||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||||
<rect key="contentRect" x="196" y="240" width="480" height="400"/>
|
<rect key="contentRect" x="196" y="240" width="480" height="400"/>
|
||||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||||
|
<connections>
|
||||||
|
<outlet property="delegate" destination="B8D-0N-5wS" id="1ov-0o-Na3"/>
|
||||||
|
</connections>
|
||||||
</window>
|
</window>
|
||||||
<connections>
|
<connections>
|
||||||
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
|
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
|
||||||
|
@ -675,23 +679,36 @@
|
||||||
<subviews>
|
<subviews>
|
||||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nbD-Cx-g7b">
|
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nbD-Cx-g7b">
|
||||||
<rect key="frame" x="20" y="252" width="204" height="128"/>
|
<rect key="frame" x="20" y="252" width="204" height="128"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="vAn-1d-apO"/>
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="vAn-1d-apO"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kv0-67-hkh">
|
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kv0-67-hkh">
|
||||||
<rect key="frame" x="256" y="252" width="204" height="128"/>
|
<rect key="frame" x="256" y="252" width="204" height="128"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="f0P-c9-GMe"/>
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="f0P-c9-GMe"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JIp-Or-vBM">
|
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JIp-Or-vBM">
|
||||||
<rect key="frame" x="20" y="116" width="204" height="128"/>
|
<rect key="frame" x="20" y="116" width="204" height="128"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="NJq-m3-LlB"/>
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="NJq-m3-LlB"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="khI-tY-l0M">
|
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="khI-tY-l0M">
|
||||||
<rect key="frame" x="256" y="116" width="204" height="128"/>
|
<rect key="frame" x="256" y="116" width="204" height="128"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="WbV-Do-9qy"/>
|
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="WbV-Do-9qy"/>
|
||||||
</imageView>
|
</imageView>
|
||||||
|
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="NqE-Zi-qhY">
|
||||||
|
<rect key="frame" x="212" y="17" width="56" height="31"/>
|
||||||
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||||
|
<buttonCell key="cell" type="bevel" title="Clear" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyUpOrDown" inset="2" id="OYN-fG-Plb">
|
||||||
|
<behavior key="behavior" pushIn="YES" changeContents="YES" lightByContents="YES"/>
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
</buttonCell>
|
||||||
|
</button>
|
||||||
</subviews>
|
</subviews>
|
||||||
</view>
|
</view>
|
||||||
<connections>
|
<connections>
|
||||||
|
<outlet property="clearCacheButton" destination="NqE-Zi-qhY" id="eoz-cU-wWs"/>
|
||||||
<outlet property="imageView1" destination="nbD-Cx-g7b" id="t2R-8w-ybH"/>
|
<outlet property="imageView1" destination="nbD-Cx-g7b" id="t2R-8w-ybH"/>
|
||||||
<outlet property="imageView2" destination="kv0-67-hkh" id="i4k-5c-bno"/>
|
<outlet property="imageView2" destination="kv0-67-hkh" id="i4k-5c-bno"/>
|
||||||
<outlet property="imageView3" destination="JIp-Or-vBM" id="Qcf-og-59T"/>
|
<outlet property="imageView3" destination="JIp-Or-vBM" id="Qcf-og-59T"/>
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
@property (weak) IBOutlet NSImageView *imageView2;
|
@property (weak) IBOutlet NSImageView *imageView2;
|
||||||
@property (weak) IBOutlet NSImageView *imageView3;
|
@property (weak) IBOutlet NSImageView *imageView3;
|
||||||
@property (weak) IBOutlet NSImageView *imageView4;
|
@property (weak) IBOutlet NSImageView *imageView4;
|
||||||
|
@property (weak) IBOutlet NSButton *clearCacheButton;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -36,6 +37,20 @@
|
||||||
self.imageView4.wantsLayer = YES;
|
self.imageView4.wantsLayer = YES;
|
||||||
self.imageView4.sd_imageTransition = SDWebImageTransition.fadeTransition;
|
self.imageView4.sd_imageTransition = SDWebImageTransition.fadeTransition;
|
||||||
[self.imageView4 sd_setImageWithURL:[NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg"] placeholderImage:nil options:SDWebImageForceTransition];
|
[self.imageView4 sd_setImageWithURL:[NSURL URLWithString:@"http://s3.amazonaws.com/fast-image-cache/demo-images/FICDDemoImage001.jpg"] placeholderImage:nil options:SDWebImageForceTransition];
|
||||||
|
|
||||||
|
self.clearCacheButton.target = self;
|
||||||
|
self.clearCacheButton.action = @selector(clearCacheButtonClicked:);
|
||||||
|
[self.clearCacheButton sd_setImageWithURL:[NSURL URLWithString:@"https://png.icons8.com/color/100/000000/delete-sign.png"]];
|
||||||
|
[self.clearCacheButton sd_setAlternateImageWithURL:[NSURL URLWithString:@"https://png.icons8.com/color/100/000000/checkmark.png"]];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)clearCacheButtonClicked:(NSResponder *)sender {
|
||||||
|
NSButton *button = (NSButton *)sender;
|
||||||
|
button.state = NSControlStateValueOn;
|
||||||
|
[[SDImageCache sharedImageCache] clearMemory];
|
||||||
|
[[SDImageCache sharedImageCache] clearDiskOnCompletion:^{
|
||||||
|
button.state = NSControlStateValueOff;
|
||||||
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setRepresentedObject:(id)representedObject {
|
- (void)setRepresentedObject:(id)representedObject {
|
||||||
|
|
Loading…
Reference in New Issue