Search This Blog

Showing posts with label XCode. Show all posts
Showing posts with label XCode. Show all posts

Sunday, March 5, 2017

UIImageView Content Modes

For new people in ios development slightly unclear how work content mode for UIImage View. What is the difference between scale modes for UIImageView?
There are three main scales modes
  • scale to fill (FILL image in UIIMageView frame - image will be changed)
  • scale aspect fit (scale image to FULLY FIT in UIIMageView frame - image will be the same but may change size)
  • scale aspect fill (scale image until smallest side fits UIImageView frame - some part of image may be clipped)
I wrote a demo program to show how this modes work.

import UIKit

class ViewController: UIViewController {
    
    @IBOutlet weak var switcher: UISwitch!
    
    @IBOutlet weak var imageView: UIImageView!
    
    @IBOutlet weak var segmentedControl: UISegmentedControl!
    
    @IBAction func segmentSelected(_ sender: Any) {
        let index = self.segmentedControl.selectedSegmentIndex
        switch index {
        case 0:
            self.imageView.contentMode = .scaleToFill
            break
        case 1:
            self.imageView.contentMode = .scaleAspectFit
            break
        case 2:
            self.imageView.contentMode = .scaleAspectFill
            break
        default:
            self.imageView.contentMode = .scaleAspectFit
            break
        }
    }
    
    @IBAction func switcherChanged(_ sender: Any) {
        self.imageView.clipsToBounds = self.switcher.isOn
    }
    
}

Original Image




Scale To Fill



Scale Aspect Fit




Scale Aspect Fill (NO Clip To Bounds)



Scale Aspect Fill (Clip To Bounds)






Tuesday, October 25, 2016

XCode 8. How to disable unwanted logs

If you start using new XCode 8 you can see a lot of unwanted logs in console. So for removing this console garbage you need to do the following:

  1. Open XCode Menu > Product > Scheme > Edit scheme...
  2. You need to add Environment Variable "OS_ACTIVITY_MODE" and set its value to disable.