Swift UIView Extension

Source: Internet
Author: User

Import foundationimport uikit//////@brief UIView extension method to facilitate engineering global use of extension methods to create or use all controls that inherit from UIView///extension UIView {/// /Gets or sets Origin.x//func Originx ()->cgfloat {return self.frame.origin.x} func Originx (Let Ori Ginx:cgfloat) {var rect = self.frame rect.origin.x = Originx self.frame = rect}/// Gets or sets ORIGIN.Y//func Originy ()->cgfloat {return SELF.FRAME.ORIGIN.Y} func originy (Let or    Iginy:cgfloat) {var rect = self.frame RECT.ORIGIN.Y = originy self.frame = rect}//  Gets or sets origin//Func origin ()->cgpoint {return Self.frame.origin} Func origin (Let Origin: Cgpoint) {var rect = self.frame Rect.origin = origin self.frame = rect}//////////Get or set  Width//func width ()->cgfloat {return self.frame.size.width} func width (let width:cgfloat) {var rect = selF.frame rect.size.width = width self.frame = rect}/////////Set height//func height () ->cgfloat {return Self.frame.size.height} func height (let height:cgfloat) {var rect = self . frame Rect.size.height = height self.frame = rect}////Get RIGHTX//func rightx ()- >cgfloat {return Originx () + width ()}////////Set bottomy//func bottomy ()->cgfloat        {return Originy () + height ()} func bottomy (let Bottomy:cgfloat) {var rect = Self.frame RECT.ORIGIN.Y = Bottomy-height () Self.frame = rect}}

Swift UIView Extension

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.