Swift ios - Các đối tượng giao diện cơ bản trong swift

Một số đối tượng cơ bản trong ngôn ngữ swift-ios

1. Đối tượng UILabel:
Khai báo : var label:UILabel! = UILabel()
  - >  Hiển thị text
  - >  Một số thuộc tính của UILabel:
        - .text  : set giá trị text cho label
           vd: labe.text = "đây là label"
        - .textColor : set màu cho text label
           vd: labe. textColor = UIColor.redColor()
        - .textAlignment : căn chỉnh trái - phải - giữa cho text label
           vd: labe. textAlignment = .center (căn giữa)
        - .frame : set vị trí cho Label
           vd: labe. frame = CGRect(0,0,50,30)
        - .backgroundColor : set màu nền cho Label 
           vd: labe. backgroundColor =  UIColor.redColor()
        - .font    : set font cho text label
           vd: labe. font = UIFont(name:"Arial", size: 14)
2. Đối tượng UIButton: 
khai báo var btnButton:UIButton! =  UIButton()
   - > Bắt sự kiện khi chúng ta tap vào button
   - > Một số thuộc tính :
        - .setBackgroundImage(UIImage), forState: UIControlState) : set nền cho button   bằng ảnh .
            VD: btnButton.setBackgroundImage(UIImage(named:"image.png")), forState: UIControlState.Normal)
        - .backgroundColor = UIColor() : set nền cho button bằng mã màu .
           VD: btnButton.backgroundColor = UIColor.redColor()
        - .setTitle("String", forState: UIControlState)  : set tiêu đề cho button
           VD: btnButton.setTitle("button", forState: UIControlState.Normal) 

        - .setTitleColor(UIColor?, forState: UIControlState) : set màu cho tiêu đề
           VD: btnButton.setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)

        - .titleLabel?.font = UIFont() : set font cho chữ tiêu đề 
           VD: btnButton.titleLabel?.font = UIFont(name:"Arial", size: 14)

        - .frame = CGRect(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) : set vị trí 
           VD: btnButton.frame = CGRect(x: 0, y: 0, width: 60, height: 30)

        - .addTarget(AnyObject?, action: Selector, forControlEvents: UIControlEvents) : thêm sự kiện                 khi tap vào button với hàm  "Selector"
           VD: btnButton.addTarget(self, action: "Selector", forControlEvents: UIControlEvents.TouchUpInside)

        - .layer.borderWidth = CGFloat  : set chiều rộng đường viền button
           VD: btnButton.layer.borderWidth = 1

        - .layer.borderColor = UIColor() : set màu cho đường viền
           VD: btnButton.layer.borderColor = UIColor.redColor()
3. Đối tượng UITextField
-> có thể nhập đoan text vào ô  TextField
- > Các thuộc tính: tương tự như UILabel
- > Đối tương này có thêm các hàm đi bắt sự kiện như : bắt đầu nhập liệu - kết thúc nhập liệu ...
4. Đối tượng UISwitch
-> on/off switch
5. Đối tượng UISlider
-> sự kiện kéo như thanh âm lượng trên ip
6. Đối tượng NSTimer
-> Tạo diễn hoạt : vd : Link Vd
7. Đối tượng UIView: 
-> Là lớp giao diện có thể chứa các đối tượng giao diên khác như  UITextField -  UISlider -  UIPickerView -  UIButton
-> add các đội tường đó bằng hàm : .addsubview(tên đối tượng)
8. Đối tượng UIPickerView
-> Là lớp giao diện của hệ thống chúng ta có thể customer để sử dụng nó :hd sau
9. Đối tượng UIAlertController
-> là đối tượng đưa ra thông báo trước khi xử lý hành động sau đó
10. Đối tượng UIProcesser
11. Đối tượng UIWebView
-> Hiển thị dữ liệu dạng html
13. Đối tượng UITableView
-> hiển thị dữ liệu trên một row(dòng) : vd https://youtu.be/U6XhH7RI5yY
14. Đối tượng UICollectionView
-> tương tự như  UITableView nhưng có thể hiển thị dữ liệu dạng lưới.

Comments

Popular posts from this blog

Tranquil Tunes: Soothing Piano & Guitar Music for Study, Work, Relaxation & Meditation

Resize - Rotate - Move View or image view in swift

NSTimer - Tạo ứng dụng đếm thời gian swift-ios