Skip to content

Commit

Permalink
Merge pull request #2 from alinradut/master
Browse files Browse the repository at this point in the history
  • Loading branch information
supercomputra authored Apr 7, 2021
2 parents 88fec27 + 625d816 commit 5ca52b6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Arale.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@
TargetAttributes = {
81B100AF219AB78E0065A3B4 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1010;
LastSwiftMigration = 1140;
};
81B100B8219AB78E0065A3B4 = {
CreatedOnToolsVersion = 10.1;
LastSwiftMigration = 1140;
};
};
};
Expand Down Expand Up @@ -374,7 +375,7 @@
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -401,7 +402,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.wiyoza.Arale;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -420,7 +421,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.wiyoza.AraleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -439,7 +440,7 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.wiyoza.AraleTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
26 changes: 24 additions & 2 deletions Arale/AraleHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import UIKit


public class AraleHeaderView: UIView {
open class AraleHeaderView: UIView {
/**
The refreshControl associated with HeaderView
Controlled by its scrollView
Expand All @@ -23,6 +23,17 @@ public class AraleHeaderView: UIView {
*/
open private(set) var backgroundImage: UIImage?

/**
Gettable image for HeaderView
Settable from init method
@return the view that is displayed on top of the image view.
*/
open private(set) var contentView: UIView = {
let contentView = UIView()
contentView.backgroundColor = .clear
return contentView
}()

/**
RefreshControl will automatically endRefreshing after reaching refreshTimoutLimit
The default is nil will animate infinitely
Expand Down Expand Up @@ -104,7 +115,7 @@ public class AraleHeaderView: UIView {
scrollView.removeObserver(self, forKeyPath: #keyPath(UIScrollView.contentOffset), context: nil)
}

public override func didMoveToSuperview() {
open override func didMoveToSuperview() {
super.didMoveToSuperview()
guard let superview = self.superview else {
return
Expand All @@ -117,6 +128,7 @@ public class AraleHeaderView: UIView {
self.scrollView = scrollView

setImageView()
setContentView()
setScrollViewContentInset()
setLayoutConstraints()
setSubviewLayoutConstraints()
Expand Down Expand Up @@ -262,6 +274,16 @@ extension AraleHeaderView {
imageView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
}

private func setContentView() {
self.addSubview(contentView)
contentView.clipsToBounds = true
contentView.translatesAutoresizingMaskIntoConstraints = false
contentView.widthAnchor.constraint(equalTo: self.widthAnchor).isActive = true
contentView.heightAnchor.constraint(equalTo: self.heightAnchor).isActive = true
contentView.centerXAnchor.constraint(equalTo: self.centerXAnchor).isActive = true
contentView.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
}

private func setScrollViewContentInset() {
guard let scrollView = self.scrollView else {
return
Expand Down

0 comments on commit 5ca52b6

Please sign in to comment.