iOS/Accessibility

[ Accessibility ] "์„ ํƒ๋จ" ์•ˆ๋‚ด ๋ฉ”์‹œ์ง€ ์ œ๊ฑฐํ•˜๊ธฐ (accessibilityTraits)

Forest Yun 2024. 12. 18. 22:25
728x90

 

 

 

 

๋ฐฐ๊ฒฝ

CollectionView ๋˜๋Š” TableView(์ดํ•˜ List ์ปดํฌ๋„ŒํŠธ)์—์„œ select ๋™์ž‘ ์‹œ ํ•ด๋‹น ์•„์ดํ…œ์˜ ์ƒํƒœ๊ฐ€ “์„ ํƒ”์œผ๋กœ ์„ค์ •๋˜์–ด ๋™์ž‘ ๋ฐ ํ™•์ธ ์‹œ VoiceOver ์Œ์„ฑ์œผ๋กœ “์„ ํƒ๋จ”์ด ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

accessibilityTraits ์„ค์ • ์ „ "์„ ํƒ๋จ"์ด ์ถœ๋ ฅ๋˜๋Š” ์˜ˆ์‹œ ์‚ฌ์ง„
accessibilityTraits ์„ค์ • ์ „ "์„ ํƒ๋จ"์ด ์ถœ๋ ฅ๋˜๋Š” ์˜ˆ์‹œ ์‚ฌ์ง„

 

 

 

 

 

 

์ ‘๊ทผ์„ฑ ๋ฌธ์ œ์˜ ์›์ธ

Apple์˜ ์˜๋„๋Š” ์•„์ดํ…œ์ด ์„ ํƒ๋˜์—ˆ์œผ๋‹ˆ๊น ํ•ด๋‹น ์•„์ดํ…œ์˜ ์ƒํƒœ๋ฅผ ์ถœ๋ ฅํ•ด ์ •ํ™•ํ•œ ์•ˆ๋‚ด๋ฅผ ํ•ด์ฃผ๊ณ ์ž ํ•จ์ด์ง€๋งŒ, ์ด๋Ÿฌํ•œ ์•ˆ๋‚ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋™์ž‘์— ๋Œ€ํ•œ ํ˜ผ๋™:

  1. “ํ•ด์ œ๋จ”์ด๋ผ๋Š” ๋ฐ˜๋Œ€ ๊ฐœ๋… ์กด์žฌ ์ธ์‹. (์˜ˆ, ์•ฝ๊ด€ ๋™์˜)
  2. ์ถ”๊ฐ€ ๊ธฐ๋Šฅ ์กด์žฌ ์ธ์‹ (์˜ˆ, ์•จ๋ฒ” - ์‚ฌ์ง„ ์„ ํƒ, ์‚ฌ์ง„ ๋ชจ์•„ ๋ณด๋‚ด๊ธฐ)

 

 

 

๊ตฌํ˜„ ๋ฐฉ๋ฒ•

์ด "์„ ํƒ๋จ"์€ accessibilityTraits๊ฐ€ .selected ๋กœ ์„ค์ •๋˜์–ด ์ถœ๋ ฅ๋˜๋Š” ๊ฒƒ์œผ๋กœ, accessibilityTraits ์„ค์ •์„ ํ†ตํ•ด ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

 

 

UIAccessibilityTraits

UIAccessibilityTraits: ์ ‘๊ทผ์„ฑ ์š”์†Œ์˜ ์ž‘๋™ ๋ฐฉ์‹์„ ์„ค๋ช…ํ•˜๋Š” ํŠน์ง•

์•„๋ž˜์™€ ๊ฐ™์ด ๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณต๋˜๋Š” ์š”์†Œ๋“ค์ด ์žˆ์–ด ํ•ด๋‹นํ•˜๋Š” ํŠน์„ฑ์„ ์ฐพ์•„ ์ž„์˜๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • button
  • link
  • image
  • header
  • select

 

 

List ์ปดํฌ๋„ŒํŠธ์˜ UIAccessibilityTraits

List ์ปดํฌ๋„ŒํŠธ์˜ ๊ธฐ๋ณธ์ ์ธ traits๋Š” .none์œผ๋กœ, ์ฆ‰ ์–ด๋–ค ํŠน์„ฑ๋„ ๊ฐ€์ง€๊ณ  ์žˆ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ์ž๊ฐ€ ์ž„์˜๋กœ ์„ค์ •ํ•ด์ฃผ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์„ค์ •๋œ traits์— ๋”ฐ๋ผ ์•ˆ๋‚ด ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

func cellRegistrationHandler(cell: UICollectionViewListCell, indexPath: IndexPath, item: Detail) {
    
    ...
    if UIAccessibility.isVoiceOverRunning {
        cell.isAccessibilityElement = true
        cell.accessibilityTraits = .button  // โญ๏ธ
    }
}



 

 

“์„ ํƒ๋จ” ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ๊ณผ ๊ด€๋ จ๋œ UIAccessibilityTraits

์—ฌ๋Ÿฌ accessibilityTraits ์ค‘ “์„ ํƒ๋จ” ์•ˆ๋‚ด ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํŠน์„ฑ์€ .selected ์ž…๋‹ˆ๋‹ค. List ์ปดํฌ๋„ŒํŠธ์—์„œ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์–ด๋–ค traits๋„ ๊ฐ€์ง€์ง€ ์•Š์ง€๋งŒ, ์„ ํƒ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ ์ž๋™์œผ๋กœ ํ•ด๋‹น ์•„์ดํ…œ์€ .selected traits๋ฅผ ๊ฐ–๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ •ํ™•ํ•˜๊ฒŒ ๋งํ•˜์ž๋ฉด accessibilityTraits๊ฐ€ button๊ณผ selected๋ฅผ ํ•จ๊ป˜ ๊ฐ€์ง„ UIAccessibilityTraits(rawValue: 9) ์œผ๋กœ ๋ณ€๊ฒฝ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ปดํฌ๋„ŒํŠธ ์ž์ฒด์— ๊ตฌํ˜„๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์„ ํƒ ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ ์ž๋™์œผ๋กœ accessibilityTraits๊ฐ€ ์„ค์ •๋˜๋ฏ€๋กœ ์ด๋ฅผ ์ฐจ๋‹จํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ํ•ด๋‹น ์†์„ฑ์˜ ์žฌ์ •์˜๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

 

 

.accessibilityTraits ์žฌ์ •์˜ ๋ฐฉ๋ฒ•

์•„๋ž˜์™€ ๊ฐ™์ด accessibilityTraits๋ฅผ ์žฌ์ •์˜ํ•ด์ค๋‹ˆ๋‹ค. get์—๋Š” ์›ํ•˜๋Š” traits์„ ์ „๋‹ฌํ•ด์ฃผ๊ณ  set์€ ์ดˆ๊ธฐํ™”ํ•ด์ฃผ์–ด ์ปดํฌ๋„ŒํŠธ์—์„œ ์ž๋™์œผ๋กœ ์„ค์ •๋˜๋Š” selected ํŠน์„ฑ์„ ์ฐจ๋‹จํ•ด์ค๋‹ˆ๋‹ค.

class ButtonTraitsCollectionListCell: UICollectionViewListCell {
    
    override var accessibilityTraits: UIAccessibilityTraits {
        get { .button }
        set {}
    }
}

 

 

 

๊ตฌํ˜„ ๊ฒฐ๊ณผ

accessibilityTraits ์„ค์ • ํ›„ "์„ ํƒ๋จ"์ด ์ œ๊ฑฐ๋œ ์˜ˆ์‹œ ์‚ฌ์ง„

 

 

728x90