UIBarButtonItemの (Swift3.0)

UIBarButtonItemの (Swift3.0)

UIBarButtonItemの (Swift3.0)

AppDelegate.swift

Preview

//

//  AppDelegate.swift

//  UIKit017

//

import UIKit

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

    

    internal var window: UIWindow?

    

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

        

        // viewConrollerを生成.

        let myViewController = ViewController()

        

        // navigationControllerを生成.

        let navigationController = UINavigationController(rootViewController: myViewController)

        

        // windowを生成.

        window = UIWindow(frame: UIScreen.mainScreen().bounds)

        

        // rootViewControllerにnavigationControllerを設定.

        window?.rootViewController = navigationController

        

        window?.makeKeyAndVisible()

        return true

    }

    

}


ViewController.swift


//

//  ViewController.swift

//  UIKit017

//

import UIKit

class ViewController: UIViewController {

    

    private var myLeftButton: UIBarButtonItem!

    private var myRightButton: UIBarButtonItem!

    

    override func viewDidLoad() {

        super.viewDidLoad()

        

        // 背景色をCyanに設定する.

        self.view.backgroundColor = UIColor.cyanColor()

        

        // NavigationControllerのタイトルを設定する.

        self.title = "My Navigation"

        

        // 左ボタンを作成する..

        myLeftButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "onClickMyButton:")

        

        // 右ボタンを作成する.

        myRightButton = UIBarButtonItem(title: "RightBtn", style: .Plain, target: self, action: "onClickMyButton:")

        

        // tagを設定する.

        myLeftButton.tag = 1

        myRightButton.tag = 2

        

        // ナビゲーションバーの左に設置する.

        self.navigationItem.leftBarButtonItem = myLeftButton

        

        // ナビゲーションバーの右に設置する.

        self.navigationItem.rightBarButtonItem = myRightButton

    }

    

    /*

    ボタンイベント.

    */

    internal func onClickMyButton(sender: UIButton){

        

        switch(sender.tag){

            

            // 背景色を青色に変える.

        case 1:

            self.view.backgroundColor = UIColor.blueColor()

            

            // 背景色を赤色に変える.

        case 2:

            self.view.backgroundColor = UIColor.redColor()

            

        default:

            print("error")

        }

    }

    

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

    }

}

actualidadiphone

Swift 3

Estamos para ayudarte: freddyhozan@gmail.com freddyhozan@nauta.cu

1 Comment

Eduardo Rodriguez Rodriguez

enero 16, 2019 at 4:37 pm

En este lugar se encuentran cosas bastante interesantes pues bien sabido es que para la comunidad del iphon todo es tan complicado en cuba siendo benébolos para no decir imposible encontrar aplicaciones para nuestros tel.
pregunto: existe alguna aplicación en la cual se pudan almacenar los archivos en un ipad 2 y poder revisarlos, eliminarlos o lo que se quiera hacer con ello.
si fueran tan amables les estaría eternamente agradecidos. de paso me gustaría encontrar un sudoku para ipad 2

Leave a Reply to Eduardo Rodriguez Rodriguez Cancelar respuesta

Sorteo Activo

Sorteo Activo

Quitar cuenta icloud 2019

     

                      COMO REALIZAR EL PAGO

    http://actualidadiphone.cubava.cu/files/2019/06/%C3%ADndice.png

     

     

Overkill 3 – Muy pronto

AdventureQuest 3D MMO RPG

Actualidad

    http://actualidadiphone.cubava.cu/files/2019/02/Screenshot-2019-2-27-SIJ%C3%9A-for-Android-APK-Download1.png

Comentarios

CURSOS EN LÍNEA