How to create a custom tab bar controller with custom tab bar shape programatticallyHow do I create delegates in Objective-C?How do I sort an NSMutableArray with custom objects in it?How to create CustomTabBarController using XIB?How to change Status Bar text color in iOSHow to hide tab bar with animation in iOS?Custom Tab Bar SwiftTab Bar Controller within Tab Bar ControllerSwitch tab bar view in subview programmatically (custom tab bar controller)Adding a custom UIViewcontroller to subview programmatically but getting an error message “Cannot convert value of type…”Swift: make custom progress view follow user tap? UIBezier
LWC SFDX source push error TypeError: LWC1009: decl.moveTo is not a function
Replacing matching entries in one column of a file by another column from a different file
High voltage LED indicator 40-1000 VDC without additional power supply
What's the output of a record needle playing an out-of-speed record
Cross compiling for RPi - error while loading shared libraries
How can I prevent hyper evolved versions of regular creatures from wiping out their cousins?
Are the number of citations and number of published articles the most important criteria for a tenure promotion?
How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?
Why is consensus so controversial in Britain?
How old can references or sources in a thesis be?
How is it possible to have an ability score that is less than 3?
Which country benefited the most from UN Security Council vetoes?
Theorems that impeded progress
RSA: Danger of using p to create q
Could an aircraft fly or hover using only jets of compressed air?
Java Casting: Java 11 throws LambdaConversionException while 1.8 does not
infared filters v nd
Does detail obscure or enhance action?
Important Resources for Dark Age Civilizations?
Codimension of non-flat locus
Watching something be written to a file live with tail
How can I make my BBEG immortal short of making them a Lich or Vampire?
What defenses are there against being summoned by the Gate spell?
Doing something right before you need it - expression for this?
How to create a custom tab bar controller with custom tab bar shape programattically
How do I create delegates in Objective-C?How do I sort an NSMutableArray with custom objects in it?How to create CustomTabBarController using XIB?How to change Status Bar text color in iOSHow to hide tab bar with animation in iOS?Custom Tab Bar SwiftTab Bar Controller within Tab Bar ControllerSwitch tab bar view in subview programmatically (custom tab bar controller)Adding a custom UIViewcontroller to subview programmatically but getting an error message “Cannot convert value of type…”Swift: make custom progress view follow user tap? UIBezier
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am trying to create my iOS mobile app entirely in code. Doing so causes problems with my custom tab bar controller with a custom tab bar shape.
My custom tab bar shape looks something along the lines of this
AppDelegate.swift:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
window = UIWindow()
window.rootViewController = CustomTabBarController()
window?.makeKeyAndVisible()
return true
In my Custom TabBarController:
import UIKit
class CustomTabBarController: UITabBarController
override func viewDidLoad()
super.viewDidLoad()
setupCenterButton()
func setupCenterButton()
let menuButton = UIButton(frame: CGRect(x: 0, y: 0, width: 64, height: 64))
var menuButtonFrame = menuButton.frame
menuButtonFrame.origin.y = view.bounds.height - menuButtonFrame.height - 48
menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.size.width/2
menuButton.frame = menuButtonFrame
menuButton.clipsToBounds = true
menuButton.layer.cornerRadius = menuButtonFrame.height/2
view.addSubview(menuButton)
extension UITabBar
open override func sizeThatFits(_ size: CGSize) -> CGSize
return CGSize(width: size.width, height: 64)
And my custom tab bar shape
import UIKit
class CustomizedTabBar: UITabBar {
private var shapeLayer: CALayer?
private func addShape()
let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath()
if let oldShapeLayer = self.shapeLayer
self.layer.replaceSublayer(oldShapeLayer, with: shapeLayer)
else
self.layer.insertSublayer(shapeLayer, at: 0)
self.shapeLayer = shapeLayer
func createPath() -> CGPath
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
//..path moving around..
path.close()
return path.cgPath
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
//..stuff
override func draw(_ rect: CGRect)
self.addShape()
func createBezierPath() -> UIBezierPath
//..creating a path
How do I get around this? With the current code setup my tabbar comes out like a normal tabbar...not my custom shape
see here
and I have tried to override my tab bar property in my UITabBarController to return an instance of my CustomizedBarBar class, with no luck. Any help would be much appreciated!
ios swift uitabbarcontroller uitabbar
add a comment |
I am trying to create my iOS mobile app entirely in code. Doing so causes problems with my custom tab bar controller with a custom tab bar shape.
My custom tab bar shape looks something along the lines of this
AppDelegate.swift:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
window = UIWindow()
window.rootViewController = CustomTabBarController()
window?.makeKeyAndVisible()
return true
In my Custom TabBarController:
import UIKit
class CustomTabBarController: UITabBarController
override func viewDidLoad()
super.viewDidLoad()
setupCenterButton()
func setupCenterButton()
let menuButton = UIButton(frame: CGRect(x: 0, y: 0, width: 64, height: 64))
var menuButtonFrame = menuButton.frame
menuButtonFrame.origin.y = view.bounds.height - menuButtonFrame.height - 48
menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.size.width/2
menuButton.frame = menuButtonFrame
menuButton.clipsToBounds = true
menuButton.layer.cornerRadius = menuButtonFrame.height/2
view.addSubview(menuButton)
extension UITabBar
open override func sizeThatFits(_ size: CGSize) -> CGSize
return CGSize(width: size.width, height: 64)
And my custom tab bar shape
import UIKit
class CustomizedTabBar: UITabBar {
private var shapeLayer: CALayer?
private func addShape()
let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath()
if let oldShapeLayer = self.shapeLayer
self.layer.replaceSublayer(oldShapeLayer, with: shapeLayer)
else
self.layer.insertSublayer(shapeLayer, at: 0)
self.shapeLayer = shapeLayer
func createPath() -> CGPath
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
//..path moving around..
path.close()
return path.cgPath
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
//..stuff
override func draw(_ rect: CGRect)
self.addShape()
func createBezierPath() -> UIBezierPath
//..creating a path
How do I get around this? With the current code setup my tabbar comes out like a normal tabbar...not my custom shape
see here
and I have tried to override my tab bar property in my UITabBarController to return an instance of my CustomizedBarBar class, with no luck. Any help would be much appreciated!
ios swift uitabbarcontroller uitabbar
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
Please show us the code where are you using yourCustomizedBarBarwith default tab bar.
– Amber K
Mar 9 at 6:00
add a comment |
I am trying to create my iOS mobile app entirely in code. Doing so causes problems with my custom tab bar controller with a custom tab bar shape.
My custom tab bar shape looks something along the lines of this
AppDelegate.swift:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
window = UIWindow()
window.rootViewController = CustomTabBarController()
window?.makeKeyAndVisible()
return true
In my Custom TabBarController:
import UIKit
class CustomTabBarController: UITabBarController
override func viewDidLoad()
super.viewDidLoad()
setupCenterButton()
func setupCenterButton()
let menuButton = UIButton(frame: CGRect(x: 0, y: 0, width: 64, height: 64))
var menuButtonFrame = menuButton.frame
menuButtonFrame.origin.y = view.bounds.height - menuButtonFrame.height - 48
menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.size.width/2
menuButton.frame = menuButtonFrame
menuButton.clipsToBounds = true
menuButton.layer.cornerRadius = menuButtonFrame.height/2
view.addSubview(menuButton)
extension UITabBar
open override func sizeThatFits(_ size: CGSize) -> CGSize
return CGSize(width: size.width, height: 64)
And my custom tab bar shape
import UIKit
class CustomizedTabBar: UITabBar {
private var shapeLayer: CALayer?
private func addShape()
let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath()
if let oldShapeLayer = self.shapeLayer
self.layer.replaceSublayer(oldShapeLayer, with: shapeLayer)
else
self.layer.insertSublayer(shapeLayer, at: 0)
self.shapeLayer = shapeLayer
func createPath() -> CGPath
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
//..path moving around..
path.close()
return path.cgPath
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
//..stuff
override func draw(_ rect: CGRect)
self.addShape()
func createBezierPath() -> UIBezierPath
//..creating a path
How do I get around this? With the current code setup my tabbar comes out like a normal tabbar...not my custom shape
see here
and I have tried to override my tab bar property in my UITabBarController to return an instance of my CustomizedBarBar class, with no luck. Any help would be much appreciated!
ios swift uitabbarcontroller uitabbar
I am trying to create my iOS mobile app entirely in code. Doing so causes problems with my custom tab bar controller with a custom tab bar shape.
My custom tab bar shape looks something along the lines of this
AppDelegate.swift:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
window = UIWindow()
window.rootViewController = CustomTabBarController()
window?.makeKeyAndVisible()
return true
In my Custom TabBarController:
import UIKit
class CustomTabBarController: UITabBarController
override func viewDidLoad()
super.viewDidLoad()
setupCenterButton()
func setupCenterButton()
let menuButton = UIButton(frame: CGRect(x: 0, y: 0, width: 64, height: 64))
var menuButtonFrame = menuButton.frame
menuButtonFrame.origin.y = view.bounds.height - menuButtonFrame.height - 48
menuButtonFrame.origin.x = view.bounds.width/2 - menuButtonFrame.size.width/2
menuButton.frame = menuButtonFrame
menuButton.clipsToBounds = true
menuButton.layer.cornerRadius = menuButtonFrame.height/2
view.addSubview(menuButton)
extension UITabBar
open override func sizeThatFits(_ size: CGSize) -> CGSize
return CGSize(width: size.width, height: 64)
And my custom tab bar shape
import UIKit
class CustomizedTabBar: UITabBar {
private var shapeLayer: CALayer?
private func addShape()
let shapeLayer = CAShapeLayer()
shapeLayer.path = createPath()
if let oldShapeLayer = self.shapeLayer
self.layer.replaceSublayer(oldShapeLayer, with: shapeLayer)
else
self.layer.insertSublayer(shapeLayer, at: 0)
self.shapeLayer = shapeLayer
func createPath() -> CGPath
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
//..path moving around..
path.close()
return path.cgPath
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool
//..stuff
override func draw(_ rect: CGRect)
self.addShape()
func createBezierPath() -> UIBezierPath
//..creating a path
How do I get around this? With the current code setup my tabbar comes out like a normal tabbar...not my custom shape
see here
and I have tried to override my tab bar property in my UITabBarController to return an instance of my CustomizedBarBar class, with no luck. Any help would be much appreciated!
ios swift uitabbarcontroller uitabbar
ios swift uitabbarcontroller uitabbar
edited Mar 9 at 3:22
asteezy24
asked Mar 9 at 0:54
asteezy24asteezy24
61
61
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
Please show us the code where are you using yourCustomizedBarBarwith default tab bar.
– Amber K
Mar 9 at 6:00
add a comment |
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
Please show us the code where are you using yourCustomizedBarBarwith default tab bar.
– Amber K
Mar 9 at 6:00
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
Please show us the code where are you using your
CustomizedBarBar with default tab bar.– Amber K
Mar 9 at 6:00
Please show us the code where are you using your
CustomizedBarBar with default tab bar.– Amber K
Mar 9 at 6:00
add a comment |
1 Answer
1
active
oldest
votes
Please try and run this way, and let me know.
class MyTab: UITabBar
class MyTabBarController: UITabBarController
override var tabBar: UITabBar
return MyTab()
I tried this with no luck
– asteezy24
Mar 9 at 20:49
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072940%2fhow-to-create-a-custom-tab-bar-controller-with-custom-tab-bar-shape-programattic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Please try and run this way, and let me know.
class MyTab: UITabBar
class MyTabBarController: UITabBarController
override var tabBar: UITabBar
return MyTab()
I tried this with no luck
– asteezy24
Mar 9 at 20:49
add a comment |
Please try and run this way, and let me know.
class MyTab: UITabBar
class MyTabBarController: UITabBarController
override var tabBar: UITabBar
return MyTab()
I tried this with no luck
– asteezy24
Mar 9 at 20:49
add a comment |
Please try and run this way, and let me know.
class MyTab: UITabBar
class MyTabBarController: UITabBarController
override var tabBar: UITabBar
return MyTab()
Please try and run this way, and let me know.
class MyTab: UITabBar
class MyTabBarController: UITabBarController
override var tabBar: UITabBar
return MyTab()
answered Mar 9 at 6:03
Amber KAmber K
321213
321213
I tried this with no luck
– asteezy24
Mar 9 at 20:49
add a comment |
I tried this with no luck
– asteezy24
Mar 9 at 20:49
I tried this with no luck
– asteezy24
Mar 9 at 20:49
I tried this with no luck
– asteezy24
Mar 9 at 20:49
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072940%2fhow-to-create-a-custom-tab-bar-controller-with-custom-tab-bar-shape-programattic%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I am not sure but try to add layer as mask.
– Prashant Tukadiya
Mar 9 at 4:43
Please show us the code where are you using your
CustomizedBarBarwith default tab bar.– Amber K
Mar 9 at 6:00