iOSのタブバーに画像付きボタンでハックする
iOSのタブバーに画像付きボタンを出すことでタブバーハックをしましょう。ハックすることで、通常のタブバーよりもアイキャッチを取ることが可能です。
TabBarの配下に入る画面ですべてでBaseViewController経由で継承すれば良いです。
BaseViewController.swift
import UIKit
class BaseViewController: UIViewController {
func appendCenterButton() {
let button: UIButton! = UIButton.buttonWithType(UIButtonType.Custom) as? UIButton
let image: UIImage? = UIImage(named:"button")
button.setImage(image, forState: UIControlState.Normal)
button.frame = CGRectMake(0, 0, 60, 70)
button.addTarget(self, action: "onClick:", forControlEvents:.TouchUpInside)
button.layer.position = CGPoint(x: self.view.frame.width / 2, y: UIScreen.mainScreen().bounds.size.height - button.frame.height + 40)
button.layer.borderWidth = 0
self.tabBarController?.view.addSubview(button)
}
@IBAction func onClick(sender: AnyObject) {
var storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
var mainViewController: UIViewController
mainViewController = storyboard.instantiateViewControllerWithIdentifier("data") as UIViewController
// タブバーを非表示にする
mainViewController.hidesBottomBarWhenPushed = true;
self.navigationController?.pushViewController(mainViewController as UIViewController, animated: true)
}
}
Author And Source
この問題について(iOSのタブバーに画像付きボタンでハックする), 我々は、より多くの情報をここで見つけました https://qiita.com/yuubon/items/c4d9e8923775ae03353a著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .