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;
    }
  • 相关阅读:
    Java日期相关操作
    Java中this的功能与作用
    DCL双检查锁机制实现的线程安全的单例模式
    Java 二分查找
    Java冒泡排序
    Java多线程编程(二)
    SSH小结
    Python快速上手JSON指南
    趣谈、浅析CRLF和LF
    linux开发神器--Tmux
  • 原文地址:https://www.cnblogs.com/javastart/p/8866445.html
Copyright © 2011-2022 走看看