加拿大28预测-加拿大28凤凰预测-加拿大28预测网站

来自 娱乐 / 影视影评 2019-10-07 15:17 的文章
当前位置: 加拿大28预测 > 娱乐 / 影视影评 > 正文

THE SWIFT CODE之UITEXTFIELD的使用,及事件委托

    妳知道『最後的晚餐』裏有一個女人嗎?妳知道基督教的『聖盃』的真正含義嗎?
    我總算可以訢賞到這部聞名已久的大片le!!我說的是『達芬奇密碼』。
    說實話,盡管很多人說這部片怎麼沒意思,我依然很喜歡這部片。
    道理很簡單。有冒險、有懸疑、有兇殺、有智謀,最重要的,我很喜歡這部片告訴我的關于西方的歷史,不,應該說是歐洲的一些歷史。影片用le很大的篇幅來展示歐洲,應該說是從公元開始,涉及到人文、地理、軍事、宗教、文化、藝術...說真的,所有的這些全部都是源于耶穌基督。至少我是這麼理解的。
    影片談到le很多史實,其實我不知道是不是史實來的,也可能是虛搆的,不過我覺得看得很過癮。就好比甚麼呢?就好比,有點『尋秦記』的味道。用現在人的角度,重新全盤地告訴妳歷史上髮生的事情,對人類影響非常大的事情,然後牽扯到很多的名人,讓妳驚呼原來歷史是這個樣子的
!再說,偶本人嚮來對歐洲的文化有點興趣,所以看看這部電影,正好符閤我的胃口le。
    最後說一句,這部電影在拍攝史實的時候的畫麵,那種質感像極le週傑倫的『夜的第七章』,呵呵,是不是有借鑑就不得而知le。
    關于宗教的神祕和其中錯綜復雜的流派關繫和權利鬥爭,以及由此導緻的人類社會髮生的大事,直到現在還在影響着人類世界。而原作者寫這部小說的意義,是不是也就是因為這個呢?
                                   2006.09.23.

UITextField是用来文本输入的,比如常用的登录用户名和密码输入等等,那我们直接进入主题吧

CODE:

27楼 2006年9月23日 20时38分23秒

加拿大28预测,1.创建普通的UITextField

#!/usr/bin/python 
# -*- coding: utf-8 -*-

'''
Created on 2014-8-6
@author: guaguastd
@name: http.py
'''

# Request over http
def request_over_http(access_token, url, fields):

    # import requests
    import requests

    # Build the urls
    urls = '%s?fields=%s&access_token=%s' % (url, fields, access_token)
    print 'urls: ', urls

    # Get the content
    content = requests.get(urls, verify=False).json()

    # return
    return content



#!/usr/bin/python 
# -*- coding: utf-8 -*-

'''
Created on 2014-8-7
@author: guaguastd
@name: graph_api_request.py
'''

import json

from http import request_over_http

url = 'https://graph.facebook.com/me'
access_token = ''

# Get 10 likes for 10 friends
fields = 'id,name,friends.limit(10).fields(likes.limit(10))'
content = request_over_http(access_token, url, fields)
print json.dumps(content, indent=1)

//构建基本的UITextField
var uitf:UITextField = UITextField(frame: CGRect(x: 50, y: 50, width: 200, height: 30))
uitf.backgroundColor = UIColor.whiteColor()
uitf.placeholder = "普通UITextField"
2.构建密码输入框

RESULT:

var uitf1:UITextField = UITextField(frame: CGRect(x: 50, y: 90, width: 200, height: 35))
uitf1.placeholder = "密码输入框"
uitf1.borderStyle = UITextBorderStyle.RoundedRect //边框样式
uitf1.backgroundColor = UIColor.whiteColor()
uitf1.secureTextEntry = true //密码输入框
3.设置UITextField的左边视图

{
 "friends": {
  "paging": {
   "next": "https://graph.facebook.com/v1.0/100006272283550/friends?limit=10&fields=likes.limit%2810%29&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&offset=10&__after_id=enc_Aeyi-ryRJ8KKYuH3F9k8nuPblpv9iCVVmzo8up78NxwEE25Q0XtdwqbYMRtPJszzrEZCE1Db2rVMCXL229StbZuh"
  }, 
  "data": [
   {
    "id": "1568560418", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "MjgyNTg1Njk4NTA4MzQ1", 
       "before": "NjM2MjA0Mjk5Nzg4NjEw"
      }, 
      "next": "https://graph.facebook.com/v1.0/1568560418/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=MjgyNTg1Njk4NTA4MzQ1"
     }, 
     "data": [
      {
       "category": "Community organization", 
       "created_time": "2014-05-28T03:12:01+0000", 
       "name": "Mil maneras de decirle sutilmente a alguien que no te gusta", 
       "id": "636204299788610"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-05-02T00:22:56+0000", 
       "name": "BOCA", 
       "category_list": [
        {
         "id": "1801", 
         "name": "Professional Sports Team"
        }
       ], 
       "id": "114264528738492"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-02-13T01:21:46+0000", 
       "name": "Hipu00f3dromo de Lincoln fotografu00edas", 
       "id": "195376183994226"
      }, 
      {
       "category": "Product/service", 
       "created_time": "2013-04-28T19:34:45+0000", 
       "name": "Samsung Mobile", 
       "id": "114219621960016"
      }, 
      {
       "category": "Product/service", 
       "created_time": "2013-03-16T15:24:29+0000", 
       "name": "Mozilla Firefox", 
       "id": "14696440021"
      }, 
      {
       "category": "Food/beverages", 
       "created_time": "2013-03-14T00:08:13+0000", 
       "name": "Cerveza Brahma", 
       "id": "69004099657"
      }, 
      {
       "category": "Entertainment website", 
       "created_time": "2013-03-04T02:27:37+0000", 
       "name": "Cau00fa Cau00fa - MiXto", 
       "id": "276098382433624"
      }, 
      {
       "category": "Society/culture website", 
       "created_time": "2013-02-21T02:00:28+0000", 
       "name": "Aun Sigooo Pensando En TI", 
       "id": "101431640015012"
      }, 
      {
       "category": "Community", 
       "created_time": "2013-01-17T00:10:34+0000", 
       "name": "Nada es lo mismo sin Futbol", 
       "id": "518822228157833"
      }, 
      {
       "category": "Website", 
       "created_time": "2012-12-05T09:53:21+0000", 
       "name": "Destander Internacional", 
       "id": "282585698508345"
      }
     ]
    }
   }, 
   {
    "id": "100002532817761", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "NTEyOTY4Nzg4NzM2Mzc3", 
       "before": "NDc5NjA3MzAyMTAxOTc3"
      }, 
      "next": "https://graph.facebook.com/v1.0/100002532817761/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=NTEyOTY4Nzg4NzM2Mzc3"
     }, 
     "data": [
      {
       "category": "Games/toys", 
       "created_time": "2014-06-14T19:19:29+0000", 
       "name": "Hra Pou", 
       "id": "479607302101977"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-05-24T23:44:54+0000", 
       "name": "El Linqueu00f1o", 
       "id": "109679792391529"
      }, 
      {
       "category": "Website", 
       "created_time": "2014-05-06T01:13:54+0000", 
       "name": "Aprender a ser feliz", 
       "id": "260719930611785"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-03-18T23:37:44+0000", 
       "name": "Bernardita", 
       "id": "1480890645464677"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-03-07T21:32:31+0000", 
       "name": "Facu ledesma", 
       "id": "414627398579431"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-03-07T16:54:08+0000", 
       "name": "The Vis", 
       "id": "754043891277599"
      }, 
      {
       "category": "City", 
       "created_time": "2014-02-27T13:19:57+0000", 
       "name": "Junu00edn, Buenos Aires", 
       "category_list": [
        {
         "id": "224455390913969", 
         "name": "City"
        }
       ], 
       "id": "108378849192690"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-02-22T01:48:48+0000", 
       "name": "Egoo lincoln", 
       "category_list": [
        {
         "id": "110290705711626", 
         "name": "Bar"
        }
       ], 
       "id": "615927198434627"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-02-20T18:26:00+0000", 
       "name": "Porta", 
       "id": "13909772021"
      }, 
      {
       "category": "Just for fun", 
       "created_time": "2014-02-18T21:35:44+0000", 
       "name": "Crea Carteles", 
       "id": "512968788736377"
      }
     ]
    }
   }, 
   {
    "id": "100004245243800", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "MjIzNjc0NzExMDUwNjMz", 
       "before": "MjkxMTkyMDA3NTU4MjE1"
      }, 
      "next": "https://graph.facebook.com/v1.0/100004245243800/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=MjIzNjc0NzExMDUwNjMz"
     }, 
     "data": [
      {
       "category": "Musician/band", 
       "created_time": "2014-07-26T17:45:39+0000", 
       "name": "Casi Justicia Social", 
       "id": "291192007558215"
      }, 
      {
       "category": "Athlete", 
       "created_time": "2014-07-15T03:30:07+0000", 
       "name": "Leo Messi", 
       "id": "176063032413299"
      }, 
      {
       "category": "Concert tour", 
       "created_time": "2014-06-19T14:53:14+0000", 
       "name": "Rocanrol del Pau00eds", 
       "category_list": [
        {
         "id": "189811544396762", 
         "name": "Tour Company"
        }, 
        {
         "id": "189483194405517", 
         "name": "Music Production"
        }
       ], 
       "id": "120829411335868"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-04-25T05:57:38+0000", 
       "name": "Casi Justicia Social", 
       "id": "186801098006391"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-04-13T00:34:42+0000", 
       "name": "Patricio Santos Fontanet", 
       "id": "129227477145991"
      }, 
      {
       "category": "Clothing", 
       "created_time": "2014-04-11T00:59:20+0000", 
       "name": "Pink Sowa", 
       "id": "315625671848264"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-04-11T00:58:41+0000", 
       "name": "Carla Alzarise Make Up", 
       "id": "635673476494422"
      }, 
      {
       "category": "Artist", 
       "created_time": "2014-04-11T00:58:14+0000", 
       "name": "Pau Scarso Photography", 
       "id": "311476752304841"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-04-02T14:49:23+0000", 
       "name": "Callejeros", 
       "id": "112518935427743"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-01-10T04:41:06+0000", 
       "name": "Desmotivaciones", 
       "id": "223674711050633"
      }
     ]
    }
   }, 
   {
    "id": "100005898397613", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "NzI5NTU4NTQwMzk1NzAy", 
       "before": "NDczMDU1MzUyNzYwNzQw"
      }, 
      "next": "https://graph.facebook.com/v1.0/100005898397613/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=NzI5NTU4NTQwMzk1NzAy"
     }, 
     "data": [
      {
       "category": "Artist", 
       "created_time": "2014-07-21T21:28:06+0000", 
       "name": "Mariia", 
       "id": "473055352760740"
      }, 
      {
       "category": "Public figure", 
       "created_time": "2014-03-26T01:34:49+0000", 
       "name": "Yo querer Comidaaaaaaaa", 
       "id": "1485476044997944"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-03-04T06:08:39+0000", 
       "name": "Justin Bieber", 
       "category_list": [
        {
         "id": "180164648685982", 
         "name": "Bands & Musicians"
        }
       ], 
       "id": "67253243887"
      }, 
      {
       "category": "Dancer", 
       "created_time": "2014-03-04T05:59:27+0000", 
       "name": "Odio a violetta", 
       "id": "477044532392301"
      }, 
      {
       "category": "Just for fun", 
       "created_time": "2014-03-04T00:17:31+0000", 
       "name": "Hay Si Voy A Llorar Por Que No Me Hablas", 
       "id": "200571013335090"
      }, 
      {
       "category": "Artist", 
       "created_time": "2014-03-01T19:12:16+0000", 
       "name": "ElrusOMG", 
       "id": "243428735824540"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-03-01T19:07:05+0000", 
       "name": "Mundo De Chicas", 
       "id": "712814788750011"
      }, 
      {
       "category": "Book", 
       "created_time": "2014-03-01T19:05:01+0000", 
       "name": "Alone With Vampire", 
       "id": "1428572367384217"
      }, 
      {
       "category": "Public figure", 
       "created_time": "2014-03-01T19:05:01+0000", 
       "name": "u0627u0635u0639u0628 u0637u0631u064au0642", 
       "id": "394277387335472"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-03-01T19:04:57+0000", 
       "name": "Katerine Acosta Y Candela Ojeda", 
       "id": "729558540395702"
      }
     ]
    }
   }, 
   {
    "id": "100006621541500", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "NTQ1ODY1MDI1NDQ0Mjc1", 
       "before": "Mjc1NDA0MDc5MjAwNzQz"
      }, 
      "next": "https://graph.facebook.com/v1.0/100006621541500/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=NTQ1ODY1MDI1NDQ0Mjc1"
     }, 
     "data": [
      {
       "category": "Artist", 
       "created_time": "2014-08-01T06:39:22+0000", 
       "name": "u00d1engo Flow", 
       "id": "275404079200743"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-29T08:22:03+0000", 
       "name": "Bebes con swag", 
       "id": "151647501700035"
      }, 
      {
       "category": "Fictional character", 
       "created_time": "2014-07-29T08:15:40+0000", 
       "name": "AMI TAMBIEN ME CONFUNDEN LOS MELLISOS", 
       "id": "157790577615959"
      }, 
      {
       "category": "Book", 
       "created_time": "2014-07-29T08:14:04+0000", 
       "name": "los bebes mas lindos", 
       "id": "253170598035126"
      }, 
      {
       "category": "Album", 
       "created_time": "2014-07-29T08:09:37+0000", 
       "name": "Los bebes mas hermosos", 
       "id": "433409126748083"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-29T08:00:33+0000", 
       "name": "Niall horan i'm in love with you", 
       "id": "128806290603262"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-29T08:00:32+0000", 
       "name": "Liam Payne", 
       "id": "352476444849191"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-29T08:00:30+0000", 
       "name": "Niall Horan.", 
       "id": "351529728293010"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-29T08:00:28+0000", 
       "name": "1D Are My Super Humans", 
       "id": "220658024722975"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-29T08:00:26+0000", 
       "name": "Tributo a One Direction - Peru00fa", 
       "id": "545865025444275"
      }
     ]
    }
   }, 
   {
    "id": "100006854221707", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "Mzc0MDQ5NTg2MDUwOTA0", 
       "before": "MjE3NTMxMDY0OTMzMDM5"
      }, 
      "next": "https://graph.facebook.com/v1.0/100006854221707/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=Mzc0MDQ5NTg2MDUwOTA0"
     }, 
     "data": [
      {
       "category": "Community", 
       "created_time": "2014-07-31T02:49:30+0000", 
       "name": "Desparramados de Nueva Chicago", 
       "id": "217531064933039"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-31T02:49:14+0000", 
       "name": "CEF 69", 
       "id": "143952422291988"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-31T02:49:04+0000", 
       "name": "Lluvias, besos, silencios, lunas y esas miradas que tanto extrau00f1o", 
       "id": "253048448145765"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-31T02:48:59+0000", 
       "name": "Tu & yo pareja perfecta", 
       "id": "503778376303648"
      }, 
      {
       "category": "Entertainer", 
       "created_time": "2014-07-31T02:48:57+0000", 
       "name": "Te invito a ser feliz, yo pago", 
       "id": "408359209198171"
      }, 
      {
       "category": "Actor/director", 
       "created_time": "2014-07-13T15:33:38+0000", 
       "name": "Av.Brasil", 
       "id": "191707154353786"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-07-13T15:33:32+0000", 
       "name": "Brasil decime que se siente.", 
       "id": "1513572578862384"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-07-13T15:33:30+0000", 
       "name": "Hincha de Nueva Chicago desde la cuna hasta el infinito", 
       "id": "300423600055252"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-10T14:21:59+0000", 
       "name": "Te Amo Y Que Algu00fan Problema", 
       "id": "653444204702887"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-07-05T21:41:29+0000", 
       "name": "u30c4Eres Adicto Al Pou,Admitelou30c4", 
       "id": "374049586050904"
      }
     ]
    }
   }, 
   {
    "id": "100006992200890", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "MTIzOTU2NDkwOTQ5ODI5", 
       "before": "MTIzOTU2NDkwOTQ5ODI5"
      }
     }, 
     "data": [
      {
       "category": "School", 
       "created_time": "2013-11-08T07:07:45+0000", 
       "name": "u6538u53bfu4e00u4e2d", 
       "id": "123956490949829"
      }
     ]
    }
   }, 
   {
    "id": "100007488665589", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "MjEwMjg1NzQ5MDg5NzIx", 
       "before": "MTA4MTc5MjI1ODczODcw"
      }
     }, 
     "data": [
      {
       "category": "Professional sports team", 
       "created_time": "2014-06-22T17:21:02+0000", 
       "name": "Boca Juniors", 
       "id": "108179225873870"
      }, 
      {
       "category": "Website", 
       "created_time": "2014-06-19T19:52:16+0000", 
       "name": "Mis Carteles", 
       "id": "478799118806621"
      }, 
      {
       "category": "Sports league", 
       "created_time": "2014-06-02T19:41:31+0000", 
       "name": "Pasion Xeneize", 
       "id": "602688296504767"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-05-06T03:05:33+0000", 
       "name": "Prince Royce", 
       "id": "116842969002"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-05-06T03:05:31+0000", 
       "name": "Romeo Santos", 
       "id": "117414898335812"
      }, 
      {
       "category": "Public figure", 
       "created_time": "2014-02-13T19:15:06+0000", 
       "name": "Cristian Gomez", 
       "id": "565275260213609"
      }, 
      {
       "category": "Food/beverages", 
       "created_time": "2014-01-25T01:36:34+0000", 
       "name": "Tang Argentina", 
       "id": "210285749089721"
      }
     ]
    }
   }, 
   {
    "id": "100007752073848", 
    "likes": {
     "paging": {
      "cursors": {
       "after": "Mjk4MTc1NzEwMzU4MzEz", 
       "before": "MTA3OTIzMzYyNTYxMjUy"
      }, 
      "next": "https://graph.facebook.com/v1.0/100007752073848/likes?limit=10&access_token=CAACEdEose0cpCIdzroQUzDoFprh9KgTx1tytqbloqc7Ca31WNdubO8MdFJjzLB9ZCID3J07NoUxX8VyEZD&after=Mjk4MTc1NzEwMzU4MzEz"
     }, 
     "data": [
      {
       "category": "Athlete", 
       "created_time": "2014-06-05T00:42:01+0000", 
       "name": "Carlos Tevez", 
       "id": "107923362561252"
      }, 
      {
       "category": "Athlete", 
       "created_time": "2014-06-05T00:41:58+0000", 
       "name": "Juan Roman Riquelme Web", 
       "id": "65239713915"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-06-05T00:41:51+0000", 
       "name": "Skrillex", 
       "id": "119702488081975"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-06-05T00:41:40+0000", 
       "name": "Miley Cyrus", 
       "id": "5845317146"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-06-05T00:41:26+0000", 
       "name": "BOCA", 
       "category_list": [
        {
         "id": "1801", 
         "name": "Professional Sports Team"
        }
       ], 
       "id": "114264528738492"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-06-05T00:41:25+0000", 
       "name": "SoyBoca", 
       "id": "128436247184676"
      }, 
      {
       "category": "Professional sports team", 
       "created_time": "2014-06-05T00:41:24+0000", 
       "name": "Boca Juniors", 
       "id": "108179225873870"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-05-29T04:32:05+0000", 
       "name": "Usher", 
       "id": "6564142497"
      }, 
      {
       "category": "Musician/band", 
       "created_time": "2014-05-29T03:59:40+0000", 
       "name": "Justin Bieber", 
       "category_list": [
        {
         "id": "180164648685982", 
         "name": "Bands & Musicians"
        }
       ], 
       "id": "67253243887"
      }, 
      {
       "category": "Community", 
       "created_time": "2014-05-27T15:11:12+0000", 
       "name": "Kevin Camacho", 
       "id": "298175710358313"
      }
     ]
    }
   }
  ]
 }, 
 "id": "100006272283550", 
 "name": "Beyond Zhou"
}

var uitf2:UITextField = UITextField(frame: CGRect(x: 50, y: 135, width: 200, height: 30))
uitf2.placeholder = "请输入购买的物品"
uitf2.backgroundColor = UIColor.whiteColor()
var img:UIImageView = UIImageView(image: UIImage(named: "buy.png")!)
img.frame = CGRect(x: 5, y: 5, width: 40, height: 30)
img.contentMode = UIViewContentMode.ScaleAspectFit
uitf2.leftView = img
uitf2.leftViewMode = UITextFieldViewMode.Always
uitf2.leftViewRectForBounds(CGRect(x: 0, y: 0, width: 44, height: 44))
4.设置UITextField的右边边视图

var uitf3:UITextField = UITextField(frame: CGRect(x: 50, y: 175, width: 200, height: 35))
uitf3.placeholder = "请输入购买的物品"
uitf3.backgroundColor = UIColor.whiteColor()
uitf3.layer.cornerRadius = 2
uitf3.layer.borderWidth = 1
uitf3.layer.borderColor = UIColor.greenColor().CGColor

//uitf3.borderStyle = UITextBorderStyle.RoundedRect
var img1:UIImageView = UIImageView(image: UIImage(named: "buy.png")!)
img1.frame = CGRect(x: 5, y: 5, width: 40, height: 30)
img1.contentMode = UIViewContentMode.ScaleAspectFit
uitf3.rightView = img1
uitf3.rightViewMode = UITextFieldViewMode.Always
5.委托事件,及加入clear按钮

var uitf4:UITextField = UITextField(frame: CGRect(x: 50, y: 220, width: 200, height: 35))
uitf4.backgroundColor = UIColor.whiteColor()
uitf4.delegate = self
uitf4.clearButtonMode = UITextFieldViewMode.WhileEditing
当鼠标进入UITextField时,响应textFieldShouldBeginEditing -> textFieldDidBeginEditing
当鼠标退出UITextField时,响应textFieldShouldEndEditing -> textFieldDidEndEditing
当输入文本内容时,响应textField
在输入框里,在虚拟键盘上点击return时,响应textFieldShouldReturn
在输入框里,点击UITextField的clear按钮,响应textFieldShouldClear

func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
    NSLog("textField")
    return true
}

func textFieldShouldBeginEditing(textField: UITextField) -> Bool {


    NSLog("textFieldShouldBeginEditing")

    return true
}

func textFieldDidBeginEditing(textField: UITextField) {

    NSLog("textFieldDidBeginEditing")
}


func textFieldShouldEndEditing(textField: UITextField) -> Bool {


    NSLog("textFieldShouldEndEditing")

    return true

}


func textFieldDidEndEditing(textField: UITextField) {

    NSLog("textFieldDidEndEditing")
}



func textFieldShouldClear(textField: UITextField) -> Bool {

    NSLog("textFieldShouldClear")

    return true
}


func textFieldShouldReturn(textField: UITextField) -> Bool {

    NSLog("textFieldShouldReturn")

    textField.resignFirstResponder() //这个隐藏(放弃)虚拟键盘

    return true

}

全部代码

import UIKit

class ViewController: UIViewController,UITextFieldDelegate {

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

    //构建基本的UITextField
    var uitf:UITextField = UITextField(frame: CGRect(x: 50, y: 50, width: 200, height: 30))
    uitf.backgroundColor = UIColor.whiteColor()
    uitf.placeholder = "普通UITextField"
    self.view.addSubview(uitf)

    //构建密码输入框
    var uitf1:UITextField = UITextField(frame: CGRect(x: 50, y: 90, width: 200, height: 35))
    uitf1.placeholder = "密码输入框"
    uitf1.borderStyle = UITextBorderStyle.RoundedRect //边框样式
    uitf1.backgroundColor = UIColor.whiteColor()
    uitf1.secureTextEntry = true //密码输入框
    self.view.addSubview(uitf1)

    //设置UITextField的左边视图
    var uitf2:UITextField = UITextField(frame: CGRect(x: 50, y: 135, width: 200, height: 30))
    uitf2.placeholder = "请输入购买的物品"
    uitf2.backgroundColor = UIColor.whiteColor()
    var img:UIImageView = UIImageView(image: UIImage(named: "buy.png")!)
    img.frame = CGRect(x: 5, y: 5, width: 40, height: 30)
    img.contentMode = UIViewContentMode.ScaleAspectFit
    uitf2.leftView = img
    uitf2.leftViewMode = UITextFieldViewMode.Always
    uitf2.leftViewRectForBounds(CGRect(x: 0, y: 0, width: 44, height: 44))
    self.view.addSubview(uitf2)


    //设置UITextField的右边边视图
    var uitf3:UITextField = UITextField(frame: CGRect(x: 50, y: 175, width: 200, height: 35))
    uitf3.placeholder = "请输入购买的物品"
    uitf3.backgroundColor = UIColor.whiteColor()
    uitf3.layer.cornerRadius = 2
    uitf3.layer.borderWidth = 1
    uitf3.layer.borderColor = UIColor.greenColor().CGColor

    //uitf3.borderStyle = UITextBorderStyle.RoundedRect
    var img1:UIImageView = UIImageView(image: UIImage(named: "buy.png")!)
    img1.frame = CGRect(x: 5, y: 5, width: 40, height: 30)
    img1.contentMode = UIViewContentMode.ScaleAspectFit
    uitf3.rightView = img1
    uitf3.rightViewMode = UITextFieldViewMode.Always
    self.view.addSubview(uitf3)

    //委托事件
    var uitf4:UITextField = UITextField(frame: CGRect(x: 50, y: 220, width: 200, height: 35))
    uitf4.backgroundColor = UIColor.whiteColor()
    uitf4.delegate = self
    uitf4.clearButtonMode = UITextFieldViewMode.WhileEditing
    self.view.addSubview(uitf4)
}


////////
// 当鼠标进入UITextField时,响应textFieldShouldBeginEditing -> textFieldDidBeginEditing
// 当鼠标退出UITextField时,响应textFieldShouldEndEditing -> textFieldDidEndEditing
// 当输入文本内容时,响应textField
// 在输入框里,在虚拟键盘上点击return时,响应textFieldShouldReturn
// 在输入框里,点击UITextField的clear按钮,响应textFieldShouldClear
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
    NSLog("textField")
    return true
}

func textFieldShouldBeginEditing(textField: UITextField) -> Bool {


    NSLog("textFieldShouldBeginEditing")

    return true
}

func textFieldDidBeginEditing(textField: UITextField) {

    NSLog("textFieldDidBeginEditing")
}


func textFieldShouldEndEditing(textField: UITextField) -> Bool {


    NSLog("textFieldShouldEndEditing")

    return true

}


func textFieldDidEndEditing(textField: UITextField) {

    NSLog("textFieldDidEndEditing")
}



func textFieldShouldClear(textField: UITextField) -> Bool {

    NSLog("textFieldShouldClear")

    return true
}


func textFieldShouldReturn(textField: UITextField) -> Bool {

    NSLog("textFieldShouldReturn")

    textField.resignFirstResponder() //这个隐藏(放弃)虚拟键盘

    return true

}

}
效果图
http://www.wutongwei.com/ueditor/jsp/upload/image/20150402/1427958750028029966.png

本文由加拿大28预测发布于娱乐 / 影视影评,转载请注明出处:THE SWIFT CODE之UITEXTFIELD的使用,及事件委托

关键词: