Skip to content

Commit

Permalink
Merge pull request #4 from parthgohel2810/bug/fix-tap-issue
Browse files Browse the repository at this point in the history
Fix tap issue
  • Loading branch information
parthgohel2810 authored May 11, 2022
2 parents 8966b4b + e80ee71 commit 84ecf46
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 116 deletions.
18 changes: 12 additions & 6 deletions Example/Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
630F8CB6282A7349007E467D /* Sources */,
630F8CB7282A7349007E467D /* Frameworks */,
630F8CB8282A7349007E467D /* Resources */,
8590075D65B51022A66420C8 /* [CP] Embed Pods Frameworks */,
1FFF88E1D4279AD486D580B6 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -175,7 +175,7 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
8590075D65B51022A66420C8 /* [CP] Embed Pods Frameworks */ = {
1FFF88E1D4279AD486D580B6 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
Expand Down Expand Up @@ -372,8 +372,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 7224G6JACN;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Example/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -388,9 +390,10 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = Mindinventory.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = MI_WildCard_Dev;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
};
Expand All @@ -400,8 +403,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 7224G6JACN;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = Example/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -416,9 +421,10 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = Mindinventory.Example;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = MI_WildCard_Dev;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
};
Expand Down
4 changes: 2 additions & 2 deletions Example/Example/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7jK-FK-vZc">
<rect key="frame" x="0.0" y="148" width="414" height="714"/>
<rect key="frame" x="0.0" y="128" width="414" height="734"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ssg-3m-7Tb" customClass="TopTabbarView" customModule="TopTabBarView">
Expand All @@ -36,7 +36,7 @@
<constraint firstItem="ssg-3m-7Tb" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" id="LK1-Wx-gtm"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="7jK-FK-vZc" secondAttribute="bottom" id="SP3-Jg-MML"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="ssg-3m-7Tb" secondAttribute="trailing" id="buZ-oA-MHn"/>
<constraint firstItem="7jK-FK-vZc" firstAttribute="top" secondItem="ssg-3m-7Tb" secondAttribute="bottom" constant="-20" id="jKJ-Qj-sTL"/>
<constraint firstItem="7jK-FK-vZc" firstAttribute="top" secondItem="ssg-3m-7Tb" secondAttribute="bottom" constant="-40" id="jKJ-Qj-sTL"/>
<constraint firstItem="7jK-FK-vZc" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" id="tog-Hb-4P9"/>
</constraints>
</view>
Expand Down
38 changes: 18 additions & 20 deletions Example/Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ViewController: UIViewController {

private var pageViewController: UIPageViewController!
private var viewControllers: [UIViewController] = []
private var collectionDataSource: [String] = ["M", "I", "N", "D", "I", "N", "V", "E", "N", "T", "O", "R", "Y"]
private var collectionDataSource: [String] = ["M", "I", "N", "D", "3", "0", "0"]

var selectedIndex: Int = 0

Expand All @@ -29,9 +29,9 @@ class ViewController: UIViewController {

topTabBarView.dataSource = collectionDataSource
topTabBarView.dotColor = .white
topTabBarView.waveHeight = 16
topTabBarView.leftPadding = 10
topTabBarView.rightPadding = 10
topTabBarView.waveHeight = 20
topTabBarView.leftPadding = 60
topTabBarView.rightPadding = 60
topTabBarView.tabBarColor = .red
view.backgroundColor = .red
topTabBarView.onItemSelected = {[weak self] (index) in
Expand All @@ -41,6 +41,20 @@ class ViewController: UIViewController {
topTabBarView.isScaleItem = true
topTabBarView.tabBarItemStyle = .setStyle(font: UIFont.boldSystemFont(ofSize: 18),
foregroundColor: .white)
topTabBarView.selectedTab = 1
applyCorner()
}

func applyCorner() {
DispatchQueue.main.async {
let rectShape = CAShapeLayer()
rectShape.bounds = self.topTabBarView.contentView.bounds
rectShape.position = self.topTabBarView.contentView.center
rectShape.path = UIBezierPath(roundedRect: self.topTabBarView.contentView.bounds, byRoundingCorners: [.bottomLeft , .bottomRight], cornerRadii: CGSize(width: 50, height: 50)).cgPath

self.topTabBarView.contentView.layer.backgroundColor = UIColor.red.cgColor
self.topTabBarView.contentView.layer.mask = rectShape
}
}

private func configurePageViewController() {
Expand All @@ -63,19 +77,3 @@ class ViewController: UIViewController {
self.pageViewController.didMove(toParent: self)
}
}

extension CGFloat {
static func random() -> CGFloat {
return CGFloat(arc4random()) / CGFloat(UInt32.max)
}
}
extension UIColor {
static func random() -> UIColor {
return UIColor(
red: .random(),
green: .random(),
blue: .random(),
alpha: 1.0
)
}
}
4 changes: 2 additions & 2 deletions TopTabBarView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'TopTabBarView'
s.version = '1.0.0'
s.version = '1.0.1'
s.summary = 'Wave animation view for tabs only used for iOS'
s.description = <<-DESC
This CocoaPods library helps you to add wave animation tabs in app and makes your app look fantastic!
Expand All @@ -9,7 +9,7 @@ DESC
s.homepage = 'https://github.com/parthgohel2810/TopTabBarView-Framework.git'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { "Parth Gohel" => "[email protected]" }
s.source = { :git => 'https://github.com/parthgohel2810/TopTabBarView-Framework.git', :branch => "development", :tag => "#v{s.version}" }
s.source = { :git => 'https://github.com/parthgohel2810/TopTabBarView-Framework.git', :tag => "#v{s.version}" }
s.platform = :ios, "13.0"
s.swift_version = '5.0'
s.ios.deployment_target = '13.0'
Expand Down
22 changes: 5 additions & 17 deletions TopTabBarView/Source/CircleView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CircleView.swift
// CustomTopBarDemo
// TopTabbarView
//
// Created by Parth Gohel on 06/05/22.
//
Expand All @@ -9,21 +9,9 @@ import Foundation
import UIKit

final class CircleView: UIView {

private let circleShapeLayer = CAShapeLayer()

var fillColor: UIColor = .red

override func draw(_ rect: CGRect) {
super.draw(rect)
drawCircle()
}

func drawCircle() {
let bezierPath = UIBezierPath()
bezierPath.addArc(withCenter: CGPoint(x: self.bounds.size.width/2, y: self.bounds.size.height/2), radius: self.frame.size.height/2, startAngle: 0, endAngle: 360, clockwise: true)
circleShapeLayer.path = bezierPath.cgPath
circleShapeLayer.fillColor = fillColor.cgColor
self.layer.insertSublayer(circleShapeLayer, at: 0)

override func layoutSubviews() {
super.layoutSubviews()
self.layer.cornerRadius = self.frame.size.height/2
}
}
31 changes: 16 additions & 15 deletions TopTabBarView/Source/TabBarCollectionView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CustomTabBar.swift
// CustomTopBarDemo
// TabBarCollectionView.swift
// TopTabbarView
//
// Created by Parth Gohel on 06/05/22.
//
Expand Down Expand Up @@ -43,25 +43,23 @@ public class TabBarCollectionView: UICollectionView {

var dotColor: UIColor = .red {
didSet {
circlePoint.fillColor = dotColor
circlePoint.backgroundColor = dotColor
}
}
internal var minimalHeight: CGFloat = 18
private var kLayerFillColor: CGColor = UIColor.red.cgColor
private var displayLink: CADisplayLink!
var count: Int = 0
private let tabBarShapeLayer = CAShapeLayer()
private var minimalY: CGFloat {
get {
return -minimalHeight
}
}
var animating = false {
didSet {
self.isUserInteractionEnabled = !animating
self.displayLink?.isPaused = !animating
if animating {
displayLink?.isPaused = false
count = 0
}
}
}

var selectedTab: Int = 1
/// Controll point of wave

private var leftPoint4 = UIView(frame: CGRect(x: 0.0, y: 0.0, width: 8, height: 8)) {
Expand Down Expand Up @@ -142,11 +140,11 @@ extension TabBarCollectionView {
addSubview(rightPoint4)
addSubview(circlePoint)
displayLink = CADisplayLink(target: self, selector: #selector(updateShapeLayer))
displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.default)
displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
displayLink?.isPaused = true
tabBarShapeLayer.fillColor = kLayerFillColor
layer.insertSublayer(tabBarShapeLayer, at: 0)
update(with: 1)
update(with: selectedTab)
updateShapeLayer()
}

Expand Down Expand Up @@ -181,11 +179,15 @@ extension TabBarCollectionView {
centerPoint2.center = CGPoint(x: imaganaeryFram.maxX + width/2, y: self.bounds.maxY)
rightPoint1.center = CGPoint(x: imaganaeryFram.midX + topOffset + 8, y: imaganaeryFram.minY)
rightPoint2.center = CGPoint(x: imaganaeryFram.maxX - bottomOffset, y: self.bounds.maxY)
circlePoint.center = CGPoint(x: leftPoint2.center.x, y: self.bounds.maxY)
circlePoint.center = CGPoint(x: leftPoint2.center.x, y: self.bounds.maxY+4)
}

/// updateShapeLayer
@objc func updateShapeLayer() {
count += 1
if count == 50 {
displayLink?.isPaused = true
}
tabBarShapeLayer.path = getCurrentPath()
}

Expand Down Expand Up @@ -213,6 +215,5 @@ extension TabBarCollectionView {
bezierPath.addLine(to: CGPoint(x: self.bounds.width, y: self.bounds.height))
bezierPath.close()
return bezierPath.cgPath

}
}
Loading

0 comments on commit 84ecf46

Please sign in to comment.