zoukankan      html  css  js  c++  java
  • 第19月第17天 uitextview 文本垂直居中 uiimage中间不拉伸

    1.

    open class VericalCenteringScrollView: UIScrollView {
        override open var contentOffset: CGPoint {
            didSet {
                let contentSize = self.contentSize
                let scrollViewSize = self.bounds.size
                
                var contentOffset = self.contentOffset
                
                if contentSize.height < scrollViewSize.height
                {
                    contentOffset.y = -(scrollViewSize.height - contentSize.height) / 2.0;
                }
                
                super.contentOffset = contentOffset
            }
        }
    }

     2.

    + (UIImage *)createLoadingImage:(UIColor *)color size:(CGSize)size centerImage:(UIImage *)image2
    {
        /*生成loadingImage,中心为image2*/
        UIGraphicsBeginImageContext(size);
        
        // Draw image1
    //    [image1 drawInRect:CGRectMake(0, 0, size.width, size.height)];
        CGRect rect=CGRectMake(0.0f, 0.0f, size.width, size.height);
        CGContextRef context = UIGraphicsGetCurrentContext();
        CGContextSetFillColorWithColor(context, [color CGColor]);
        CGContextFillRect(context, rect);
        
        // Draw image2
        [image2 drawInRect:CGRectMake((size.width-image2.size.width)/2, (size.height-image2.size.height)/2, image2.size.width, image2.size.height)];
        
        UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
        return resultingImage;
    }
  • 相关阅读:
    基于XMPP协议的Android即时通信系
    codeforces 830 B Cards Sorting
    [SCOI2007]修车
    spoj GSS4
    hdu 3652 B-number
    【模版】多项式乘法 FFT
    hdu 3642 Get The Treasury
    hdu 1255 覆盖的面积
    hdu 4553 约会安排
    UVA-11992 Fast Matrix Operations
  • 原文地址:https://www.cnblogs.com/javastart/p/8866445.html
Copyright © 2011-2022 走看看